Package org.ldaptive.beans.reflect
Class ReflectionUtils
java.lang.Object
org.ldaptive.beans.reflect.ReflectionUtils
Provides utility methods for common reflection operations.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Class<?>
Casts the supplied type to a class.static Object
Returns the value of the supplied field on the supplied object.static Object
invokeGetterMethod
(Method method, Object object) Invokes the supplied method on the supplied object.static void
invokeSetterMethod
(Method method, Object object, Object value) Invokes the supplied method on the supplied object with the supplied value as a parameter.static void
Sets the supplied value of the supplied field on the supplied object.
-
Constructor Details
-
ReflectionUtils
private ReflectionUtils()Default constructor.
-
-
Method Details
-
classFromType
Casts the supplied type to a class.- Parameters:
t
- to cast- Returns:
- class cast from t
- Throws:
IllegalArgumentException
- if t is not an instance of Class
-
getField
Returns the value of the supplied field on the supplied object.- Parameters:
field
- containing the value to returnobject
- that has the field- Returns:
- value of the field on the object
- Throws:
IllegalArgumentException
- if the field cannot be retrieved
-
setField
Sets the supplied value of the supplied field on the supplied object.- Parameters:
field
- of the object to setobject
- that has the fieldvalue
- to set- Throws:
IllegalArgumentException
- if the field cannot be set
-
invokeGetterMethod
Invokes the supplied method on the supplied object.- Parameters:
method
- to invokeobject
- that has the method- Returns:
- value of the invoked method
- Throws:
IllegalArgumentException
- if the method cannot be invoked
-
invokeSetterMethod
Invokes the supplied method on the supplied object with the supplied value as a parameter.- Parameters:
method
- to invokeobject
- that has the methodvalue
- to set- Throws:
IllegalArgumentException
- if the method cannot be invoked
-