T - the type which which can convert a string to.public abstract class PropertyType<T> extends Object implements Serializable
| Constructor and Description |
|---|
PropertyType(String typeName,
T defaultValue)
Constructs a PropertyType
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj)
Two property types are equal if their getDescription are equal.
|
T |
getDefaultValue()
The default <T> typed value
|
String |
getDefaultValueAsString() |
String |
getDefaultValueDescription()
Gets the description of the default value.
|
String |
getDescription()
Gets a description of the PropertyType which is a string version of the restrictions with a "\n" as new line divider.
|
String |
getDescription(String newLineDivider)
Gets a description of the PropertyType which is a string version of the restrictions.
|
int |
getInitializationPriority()
The priority order in which the a PropertyType is initialized Default is 99.
|
PropertyIO |
getIo()
Gets the PropertyIO assigned to the propertyType.
|
org.apache.commons.logging.Log |
getLogger()
Gets the logger.
|
abstract List<String> |
getRestrictions()
Gets a detailed description of the PropertyType with any constraints that might influence the validation.
|
String |
getTypeName()
Gets the type name of the PropertyType.
|
boolean |
hasDefaultValue()
Determines if the PropertyType has a defaultValue.
|
boolean |
isDefaultValueValid()
Determines if the default value for a PropertyType parses its own validation.
|
protected String |
postGetValueProcessing(String propertyName,
String value,
boolean propertyReadonly)
Special method invoke by the Property.getValue(), to gives the
ability to post processed the loaded value.
|
void |
setDefaultValue(T defaultValue)
Setting the default value <T> typed value
|
void |
setInitializationPriority(int initializationPriority)
Sets the initialization priority.
|
void |
setIo(PropertyIO io)
Set/assign the PropertyIO to the proprerty type.
|
void |
setTypedValue(String propertyName,
T t)
Sets/writes the types value to the PropertyIO.
|
protected void |
setTypeName(String typeName) |
String |
toString(String propertyName,
T t)
Converts a typed to the string representation.
|
T |
toType(String propertyName,
String value)
Gets the converted typed value, its presumed that a the properties
already has been validated.
|
T |
validate(String propertyName,
String value)
Validates the constraints and value of the PropertyType
and returns the value as the defined type.
|
void |
validateConstraints(String propertyName)
A PropertyType can have some constraints here is where they are
validated.
|
protected void |
validateNullType(String propertyName,
Object value)
Helper method, to validate if a type T is null, and throwing a exception
if that is the case.
|
abstract T |
validateValue(String propertyName,
String value)
Converts the string representation of to a typed value.
|
public PropertyType(String typeName, T defaultValue) throws NullPointerException
typeName - the short name if the PropertyType.defaultValue - value returned if property value is undefined.NullPointerException - if the typeName is null.public final T getDefaultValue()
null.public final void setDefaultValue(T defaultValue)
defaultValue - the default value. Setting null means no default value is set.public final boolean hasDefaultValue()
true if the defaultValue is different from null, otherwise false.public final String getTypeName()
protected final void setTypeName(String typeName)
public final String getDescription()
StringUtils.asString(List)public final String getDescription(String newLineDivider)
newLineDivider - the string your want as a new line divider.StringUtils.asString(List, String)public abstract List<String> getRestrictions()
public String toString(String propertyName, T t) throws PropertyException
propertyName - the name of the property used for logging purposes.t - the type T.PropertyException - if conversion failed in validation.validate(String, String)public void validateConstraints(String propertyName) throws PropertyException
propertyName - the name of the property used for logging purposes, to
identify the unique property which PropertyType has constraint
issues.PropertyException - if the constraints have invalid/conflicting values.Property.validate()public final T validate(String propertyName, String value) throws PropertyException
propertyName - the name of the property used for logging purposes. To uniquely identify the Property with validation issues.value - the string representation of the propertyPropertyException - if the conversion failed.public abstract T validateValue(String propertyName, String value) throws PropertyException
propertyName - the name of the property used for logging purposes. To uniquely identify the Property with validation issues.value - the string representation of the propertyPropertyException - if the conversion failed.public final T toType(String propertyName, String value)
propertyName - the name of the property used for logging purposes.value - a proper converted type, otherwise return null.null.public final void setTypedValue(String propertyName, T t) throws PropertyException
PropertyIO is not null and the the
PropertyIO is using caching, the method
"storeTypedValue(name,t)" is called.propertyName - the name of the property used for logging purposes.t - the typed value.PropertyException - if PropertyIO.setValue(String,String) fails or the toString(String, Object) fails.protected final void validateNullType(String propertyName, Object value) throws PropertyException
propertyName - the name of the property used for logging purposes.value - the typed value t.PropertyException - if t is null.public final PropertyIO getIo()
public final void setIo(PropertyIO io)
io - the PropertyIOpublic String getDefaultValueDescription()
null, then
"Use default value [null] if value is undefined".toString(String, Object)public String getDefaultValueAsString() throws PropertyException
PropertyExceptionpublic boolean isDefaultValueValid()
true if the default value is valid or
null, otherwise false.public boolean equals(Object obj)
public final org.apache.commons.logging.Log getLogger()
protected String postGetValueProcessing(String propertyName, String value, boolean propertyReadonly)
propertyName - the name of the Property used for loggingvalue - the value.propertyReadonly - if the the property is readonly or not.public final int getInitializationPriority()
public final void setInitializationPriority(int initializationPriority)
initializationPriority - the priority of the initialization.