Package org.ldaptive.props
Class AbstractPropertyInvoker
java.lang.Object
org.ldaptive.props.AbstractPropertyInvoker
- All Implemented Interfaces:
PropertyInvoker
- Direct Known Subclasses:
AuthenticationRequestPropertyInvoker,AuthenticatorPropertyInvoker,BeanGeneratorPropertyInvoker,BindConnectionInitializerPropertyInvoker,BlockingConnectionPoolPropertyInvoker,CompareAuthenticationHandlerPropertyInvoker,ConnectionConfigPropertyInvoker,DefaultConnectionFactoryPropertyInvoker,SearchOperationFactoryPropertyInvoker,SearchRequestPropertyInvoker,SimpleBindAuthenticationHandlerPropertyInvoker,SimplePropertyInvoker,SslConfigPropertyInvoker
Provides methods common to property invokers.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectconvertSimpleType(Class<?> type, String value) Converts simple types that are common to all property invokers.protected abstract ObjectconvertValue(Class<?> type, String value) Converts the supplied string value into an Object of the supplied type.protected ObjectcreateArrayEnumFromPropertyValue(Class<?> c, String s) Returns the enum array which represents the supplied class given the supplied string representation.protected ObjectcreateArrayTypeFromPropertyValue(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 ObjectcreateTypeFromPropertyValue(Class<?> c, String s) Returns the object which represents the supplied class given the supplied string representation.protected static Enum<?>Returns the enum for the supplied type and value.Returns the property keys for this invoker.booleanhasProperty(String name) Returns whether the supplied property exists for this invoker.protected voidinitialize(Class<?> c) Initializes the properties cache with the supplied class.static <T> TinstantiateType(T type, String className) Creates an instance of the supplied type.static ObjectinvokeMethod(Method method, Object object, Object arg) Invokes the supplied method on the supplied object with the supplied argument.voidsetProperty(Object object, String name, String value) This invokes the setter method for the supplied property name with the supplied value.
-
Field Details
-
PROPERTIES_CACHE
Cache of properties. -
clazz
Class to invoke methods on. -
properties
Map of all properties to their getter and setter methods.
-
-
Constructor Details
-
AbstractPropertyInvoker
public AbstractPropertyInvoker()
-
-
Method Details
-
initialize
Initializes the properties cache with the supplied class. The cache contains a map of properties to an array of the setter and getter methods. If a method named 'initialize' is found, it is also cached.- Parameters:
c- to read methods from
-
setProperty
This invokes the setter method for the supplied property name with the supplied value.- Specified by:
setPropertyin interfacePropertyInvoker- Parameters:
object- to invoke method onname- of the propertyvalue- of the property- Throws:
IllegalArgumentException- if an invocation exception occurs
-
convertValue
Converts the supplied string value into an Object of the supplied type. If value cannot be converted it is returned as is.- Parameters:
type- of object to convert value intovalue- to parse- Returns:
- object of the supplied type
-
hasProperty
Returns whether the supplied property exists for this invoker.- Specified by:
hasPropertyin interfacePropertyInvoker- Parameters:
name- to check- Returns:
- whether the supplied property exists
-
getProperties
Returns the property keys for this invoker.- Specified by:
getPropertiesin interfacePropertyInvoker- Returns:
- set of property names
-
instantiateType
Creates an instance of the supplied type.- Type Parameters:
T- type of class returned- Parameters:
type- of class to createclassName- to create- Returns:
- class of type T
- Throws:
IllegalArgumentException- if the supplied class name cannot create a new instance of T
-
createClass
Creates the class with the supplied name.- Parameters:
className- to create- Returns:
- class
- Throws:
IllegalArgumentException- if the supplied class name cannot be created
-
convertSimpleType
Converts simple types that are common to all property invokers. If value cannot be converted it is returned as is.- Parameters:
type- of object to convert value intovalue- to parse- Returns:
- object of the supplied type
-
getEnum
Returns the enum for the supplied type and value.- Parameters:
clazz- of the enumvalue- of the enum- Returns:
- enum that matches the supplied value
-
createTypeFromPropertyValue
Returns the object which represents the supplied class given the supplied string representation.- Parameters:
c- type to instantiates- property value to parse- Returns:
- the supplied type or null
-
createArrayTypeFromPropertyValue
Returns the object which represents an array of the supplied class given the supplied string representation.- Parameters:
c- type to instantiates- property value to parse- Returns:
- an array or null
-
createArrayEnumFromPropertyValue
Returns the enum array which represents the supplied class given the supplied string representation.- Parameters:
c- type to instantiates- property value to parse- Returns:
- Enum[] of the supplied type or null
-
invokeMethod
Invokes the supplied method on the supplied object with the supplied argument.- Parameters:
method- to invokeobject- to invoke method onarg- to invoke method with- Returns:
- object produced by the invocation
- Throws:
IllegalArgumentException- if an error occurs invoking the method
-