de.smartics.properties.spi.core.value
Class CollectionPropertyValueRange<T>

Package class diagram package CollectionPropertyValueRange
java.lang.Object
  extended by de.smartics.properties.spi.core.value.CollectionPropertyValueRange<T>
Type Parameters:
T - the type of the property values within the given range. Please note that the type is required to be serializable. Otherwise instances of this class are also not serializable.
All Implemented Interfaces:
PropertyValueRange<T>, Serializable

public final class CollectionPropertyValueRange<T>
     
     
extends Object
implements PropertyValueRange<T>, Serializable

Defines a set of valid enumerable elements for values of a property.

See Also:
Serialized Form

Constructor Summary
CollectionPropertyValueRange(Collection<T> values)
          Constructor accepting a collection of values.
CollectionPropertyValueRange(T[] values)
          Constructor accepting an array of values.
 
Method Summary
 boolean equals(Object object)
          Returns true if the given object is semantically equal to the given object, false otherwise.
 T fromString(String valueAsString)
          Constructs a value of the real type T from the given string representation of a value of the range.
 List<T> getValues()
          Returns the list of values provided by the property range.
 int hashCode()
          Returns the hash code of the object.
 boolean isCommented()
          Checks whether or not the values have comments.
 String toString()
          Returns the list of possible values or any form to show the the range of values to select from using the default locale.
 String toString(Locale locale)
          Returns the list of possible values or any form to show the the range of values to select from.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CollectionPropertyValueRange

public CollectionPropertyValueRange(T[] values)
                             throws de.smartics.util.lang.NullArgumentException
Constructor accepting an array of values.

Parameters:
values - the allowed values for this value range.
Throws:
de.smartics.util.lang.NullArgumentException - if values is null.

CollectionPropertyValueRange

public CollectionPropertyValueRange(Collection<T> values)
                             throws de.smartics.util.lang.NullArgumentException
Constructor accepting a collection of values.

Parameters:
values - the allowed values for this value range.
Throws:
de.smartics.util.lang.NullArgumentException - if values is null.
Method Detail

getValues

public List<T> getValues()
Description copied from interface: PropertyValueRange
Returns the list of values provided by the property range. If the empty list is returned, the values of this range are not enumerable. In this case the method PropertyValueRange.toString() returns information about the values that should be rendered instead.

Example:

For instance, if the range is restricted to prime numbers, this
method returns the empty list and the <A HREF="../../../../../../de/smartics/properties/api/core/domain/PropertyValueRange.html#toString()"><CODE>PropertyValueRange.toString()</CODE></A> method returns the
descriptive text
"Only prime numbers are allowed as values for this property.".

Specified by:
getValues in interface PropertyValueRange<T>
Returns:
the list of values provided by the property range.

fromString

public T fromString(String valueAsString)
             throws IllegalArgumentException
Description copied from interface: PropertyValueRange
Constructs a value of the real type T from the given string representation of a value of the range.

Specified by:
fromString in interface PropertyValueRange<T>
Parameters:
valueAsString - the string representation of the value.
Returns:
the value of type T.
Throws:
IllegalArgumentException - if the given string argument cannot be parsed and is therefore illegal to construct an instance of type <T>.

isCommented

public boolean isCommented()
Description copied from interface: PropertyValueRange
Checks whether or not the values have comments.

Specified by:
isCommented in interface PropertyValueRange<T>
Returns:
true if the values have comments, false if the values have no comments.

hashCode

public int hashCode()
Returns the hash code of the object.

Overrides:
hashCode in class Object
Returns:
the hash code.

equals

public boolean equals(Object object)
Returns true if the given object is semantically equal to the given object, false otherwise.

Overrides:
equals in class Object
Parameters:
object - the instance to compare to.
Returns:
true if the given object is semantically equal to the given object, false otherwise.

toString

public String toString(Locale locale)
Description copied from interface: PropertyValueRange
Returns the list of possible values or any form to show the the range of values to select from. Only in the latter case the locale is relevant. Localization of property values is (currently) out of scope.

Specified by:
toString in interface PropertyValueRange<T>
Parameters:
locale - the locale to use for formatting.
Returns:
the list of possible values or any form to show the the range of values to select from.

toString

public String toString()
Description copied from interface: PropertyValueRange
Returns the list of possible values or any form to show the the range of values to select from using the default locale.

Specified by:
toString in interface PropertyValueRange<T>
Overrides:
toString in class Object
Returns:
the list of possible values or any form to show the the range of values to select from.


Copyright © 2012-2013 Kronseder & Reiner GmbH - smartics. All Rights Reserved.