de.smartics.properties.spi.core.value
Class EnumeratedPropertyValueRange<T extends Enum<T>>

Package class diagram package EnumeratedPropertyValueRange
java.lang.Object
  extended by de.smartics.properties.spi.core.value.EnumeratedPropertyValueRange<T>
Type Parameters:
T - the type of the enumeration.
All Implemented Interfaces:
PropertyValueRange<T>, Serializable

public final class EnumeratedPropertyValueRange<T extends Enum<T>>
     
     
extends Object
implements PropertyValueRange<T>

A property value range backed up by an enumeration of values.

See Also:
Serialized Form

Constructor Summary
EnumeratedPropertyValueRange(Class<T> enumeration)
          Default constructor.
 
Method Summary
 boolean equals(Object object)
           
 T fromString(String valueAsString)
          Constructs a value of the real type T from the given string representation of a value of the range.
 Class<T> getEnumeration()
          Returns the enumeration to provide the value for this range.
 List<T> getValues()
          Returns the list of values provided by the property range.
 int hashCode()
           
 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

EnumeratedPropertyValueRange

public EnumeratedPropertyValueRange(Class<T> enumeration)
                             throws de.smartics.util.lang.NullArgumentException
Default constructor.

Parameters:
enumeration - the enumeration to provide the value for this range.
Throws:
de.smartics.util.lang.NullArgumentException - of {code enumeration} is null.
Method Detail

getEnumeration

public Class<T> getEnumeration()
Returns the enumeration to provide the value for this range.

Returns:
the enumeration to provide the value for this range.

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 extends Enum<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 extends Enum<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 extends Enum<T>>
Returns:
true if the values have comments, false if the values have no comments.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object object)
Overrides:
equals in class Object

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 extends Enum<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 extends Enum<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.