Representation of a property consisting of a name and value(s). Note that this property is immutable, meaning that the property values may not be changed through this interface.
This class is designed to be used with the {@link ValueFactories} interface and the particular {@link ValueFactory} thatcorresponds to the type of value you'd like to use. The ValueFactory
will then return the values (if no type conversion is required) or will convert the values using the appropriate conversion algorithm.
The following example shows how to obtain the {@link String} representations of the {@link #getValues() property values}:
ValueFactories valueFactories = ... Property property = ... Iterator<String> iter = valueFactories.getStringFactory().create(property.getValues()); while ( iter.hasNext() ) { System.out.println(iter.next()); }
Meanwhile, the {@link ValueFactories#getLongFactory() long value factory} converts the values to
long
, the{@link ValueFactories#getDateFactory() date value factory} converts the values to {@link DateTime} instances, and so on.
This technique is much better and far safer than casting the values. It is possible that some Property instances contain heterogeneous values, so casting may not always work. Also, this technique guarantees that the values are properly converted if the type is not what you expected.