public abstract class AbstractPropertyInvoker extends java.lang.Object implements PropertyInvoker
| Modifier and Type | Field and Description |
|---|---|
private java.lang.Class<?> |
clazz
Class to invoke methods on.
|
private java.util.Map<java.lang.String,java.lang.reflect.Method[]> |
properties
Map of all properties to their getter and setter methods.
|
private static java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.reflect.Method[]>> |
PROPERTIES_CACHE
Cache of properties.
|
| Constructor and Description |
|---|
AbstractPropertyInvoker() |
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.Object |
convertSimpleType(java.lang.Class<?> type,
java.lang.String value)
Converts simple types that are common to all property invokers.
|
protected abstract java.lang.Object |
convertValue(java.lang.Class<?> type,
java.lang.String value)
Converts the supplied string value into an Object of the supplied type.
|
protected java.lang.Object |
createArrayEnumFromPropertyValue(java.lang.Class<?> c,
java.lang.String s)
Returns the enum array which represents the supplied class given the supplied string representation.
|
protected java.lang.Object |
createArrayTypeFromPropertyValue(java.lang.Class<?> c,
java.lang.String s)
Returns the object which represents an array of the supplied class given the supplied string representation.
|
static java.lang.Class<?> |
createClass(java.lang.String className)
Creates the class with the supplied name.
|
protected java.lang.Object |
createTypeFromPropertyValue(java.lang.Class<?> c,
java.lang.String s)
Returns the object which represents the supplied class given the supplied string representation.
|
protected static java.lang.Enum<?> |
getEnum(java.lang.Class<?> clazz,
java.lang.String value)
Returns the enum for the supplied type and value.
|
java.util.Set<java.lang.String> |
getProperties()
Returns the property keys for this invoker.
|
boolean |
hasProperty(java.lang.String name)
Returns whether the supplied property exists for this invoker.
|
protected void |
initialize(java.lang.Class<?> c)
Initializes the properties cache with the supplied class.
|
static <T> T |
instantiateType(T type,
java.lang.String className)
Creates an instance of the supplied type.
|
static java.lang.Object |
invokeMethod(java.lang.reflect.Method method,
java.lang.Object object,
java.lang.Object arg)
Invokes the supplied method on the supplied object with the supplied argument.
|
void |
setProperty(java.lang.Object object,
java.lang.String name,
java.lang.String value)
This invokes the setter method for the supplied property name with the supplied value.
|
private static final java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.reflect.Method[]>> PROPERTIES_CACHE
private java.lang.Class<?> clazz
private java.util.Map<java.lang.String,java.lang.reflect.Method[]> properties
protected void initialize(java.lang.Class<?> c)
c - to read methods frompublic void setProperty(java.lang.Object object,
java.lang.String name,
java.lang.String value)
setProperty in interface PropertyInvokerobject - to invoke method onname - of the propertyvalue - of the propertyjava.lang.IllegalArgumentException - if an invocation exception occursprotected abstract java.lang.Object convertValue(java.lang.Class<?> type,
java.lang.String value)
type - of object to convert value intovalue - to parsepublic boolean hasProperty(java.lang.String name)
hasProperty in interface PropertyInvokername - to checkpublic java.util.Set<java.lang.String> getProperties()
getProperties in interface PropertyInvokerpublic static <T> T instantiateType(T type,
java.lang.String className)
T - type of class returnedtype - of class to createclassName - to createjava.lang.IllegalArgumentException - if the supplied class name cannot create a new instance of Tpublic static java.lang.Class<?> createClass(java.lang.String className)
className - to createjava.lang.IllegalArgumentException - if the supplied class name cannot be createdprotected java.lang.Object convertSimpleType(java.lang.Class<?> type,
java.lang.String value)
type - of object to convert value intovalue - to parseprotected static java.lang.Enum<?> getEnum(java.lang.Class<?> clazz,
java.lang.String value)
clazz - of the enumvalue - of the enumprotected java.lang.Object createTypeFromPropertyValue(java.lang.Class<?> c,
java.lang.String s)
c - type to instantiates - property value to parseprotected java.lang.Object createArrayTypeFromPropertyValue(java.lang.Class<?> c,
java.lang.String s)
c - type to instantiates - property value to parseprotected java.lang.Object createArrayEnumFromPropertyValue(java.lang.Class<?> c,
java.lang.String s)
c - type to instantiates - property value to parsepublic static java.lang.Object invokeMethod(java.lang.reflect.Method method,
java.lang.Object object,
java.lang.Object arg)
method - to invokeobject - to invoke method onarg - to invoke method withjava.lang.IllegalArgumentException - if an error occurs invoking the method