public abstract class AbstractPropertyTransformer extends Object implements PropertyTransformer
PropertyTransformer
interface. This implementation assumes that
,
The actual transformation of the value is delegated to transform(String)
. Subclasses must implement this method.
If the type class is an array, this method will be be invoked once pr comma separated value and the result will be
added to an array created using reflection.
If the type class is not an array, the method will be invoked once.
PropertyTransformer.PropertyDescriptor
Constructor and Description |
---|
AbstractPropertyTransformer() |
Modifier and Type | Method and Description |
---|---|
protected Object |
createArray(Class pComponentType,
int pLength)
Creates an array of the given type with the given size.
|
protected Object |
readStaticField(String pValue,
Class pPropertyType) |
Object |
transform(PropertyTransformer.PropertyDescriptor pDescriptor,
String pValue)
Transforms
pValue into an object of the provided pType . |
protected abstract Object |
transform(String pValue)
Transforms the input object (leaving it unchanged) into some output object.
|
protected Object |
transformWithFallbackToStaticFieldIfTransformationFails(String pValue,
Class pPropertyType) |
public Object transform(PropertyTransformer.PropertyDescriptor pDescriptor, String pValue) throws IllegalArgumentException, BusException
pValue
into an object of the provided pType
. If pType is an array, the
method will
transform(String)
once for each value in the arraytransform(String)
and return the value unchanged.transform
in interface PropertyTransformer
pDescriptor
- the PropertyDescriptor
describing the property we want to transform pValue
intopValue
- the object to be transformed, should be left unchangedIllegalArgumentException
- if the input is invalidBusException
- if the transformer cannot do it's jobPropertyTransformer.transform(PropertyDescriptor, String)
protected Object transformWithFallbackToStaticFieldIfTransformationFails(String pValue, Class pPropertyType) throws IllegalArgumentException, BusException
IllegalArgumentException
BusException
protected Object readStaticField(String pValue, Class pPropertyType) throws IllegalAccessException
IllegalAccessException
protected Object createArray(Class pComponentType, int pLength)
pComponentType
- the Class
object representing the component type of the new arraypLength
- the length of the new arrayprotected abstract Object transform(String pValue) throws IllegalArgumentException, BusException
pValue
- the object to be transformed, should be left unchangedIllegalArgumentException
- if the input is invalidBusException
- if the transformer cannot do it's job© 1998- 2021 Escenic AS