Interface TypeWrapper
-
- All Superinterfaces:
java.io.Serializable
- All Known Implementing Classes:
AbstractSimpleTypeWrapper,BooleanTypeWrapper,ColorTypeWrapper,EnumTypeWrapper,NumberTypeWrapper,StringTypeWrapper,TLIListTypeWrapper
public interface TypeWrapper extends java.io.SerializableEncapsulates information about a parameter's value type and how values should be converted between strings and the appropriate object instances.This allows elimination of an additional "evil" if-elseif...else" pattern.
- Version:
- $Revision: 03dc0884e86f $
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringFAILED_TO_CONVERTError message for failed to convert 1/2.static java.lang.StringTOError message for failed to convert 2/2.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.ObjectfromString(java.lang.String value)Attempts to convert a parameter value expressed as string into an instance of the appropriate (for this parameter) type.java.lang.Class<?>getValueType()java.lang.StringtoString(java.lang.Object value)Attempts to convert a parameter value expressed as an object of the appropriate (for this parameter) type into a string representation.booleanvalid(java.lang.Object o)Checks if the object is of a valid type for this type info.
-
-
-
Field Detail
-
FAILED_TO_CONVERT
static final java.lang.String FAILED_TO_CONVERT
Error message for failed to convert 1/2.- See Also:
- Constant Field Values
-
TO
static final java.lang.String TO
Error message for failed to convert 2/2.- See Also:
- Constant Field Values
-
-
Method Detail
-
getValueType
java.lang.Class<?> getValueType()
- Returns:
- the class instance being wrapped
-
valid
boolean valid(java.lang.Object o)
Checks if the object is of a valid type for this type info.- Parameters:
o- the object to check- Returns:
- true if the parameter can be set.
-
fromString
java.lang.Object fromString(java.lang.String value)
Attempts to convert a parameter value expressed as string into an instance of the appropriate (for this parameter) type.- Parameters:
value- parameter value as string- Returns:
- parameter value as an instance of the proper type
-
toString
java.lang.String toString(java.lang.Object value)
Attempts to convert a parameter value expressed as an object of the appropriate (for this parameter) type into a string representation.- Parameters:
value- parameter value as object- Returns:
- parameter value as string
-
-