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