org.ldaptive.beans.reflect
Class ReflectionUtils

java.lang.Object
  extended by org.ldaptive.beans.reflect.ReflectionUtils

public final class ReflectionUtils
extends Object

Provides utility methods for common reflection operations.

Version:
$Revision: 3013 $ $Date: 2014-07-02 11:26:52 -0400 (Wed, 02 Jul 2014) $
Author:
Middleware Services

Method Summary
static Class<?> classFromType(Type t)
          Casts the supplied type to a class.
static Object getField(Field field, Object 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 setField(Field field, Object object, Object value)
          Sets the supplied value of the supplied field on the supplied object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

classFromType

public static Class<?> classFromType(Type t)
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

public static Object getField(Field field,
                              Object object)
Returns the value of the supplied field on the supplied object.

Parameters:
field - containing the value to return
object - that has the field
Returns:
value of the field on the object
Throws:
IllegalArgumentException - if the field cannot be retrieved

setField

public static void setField(Field field,
                            Object object,
                            Object value)
Sets the supplied value of the supplied field on the supplied object.

Parameters:
field - of the object to set
object - that has the field
value - to set
Throws:
IllegalArgumentException - if the field cannot be set

invokeGetterMethod

public static Object invokeGetterMethod(Method method,
                                        Object object)
Invokes the supplied method on the supplied object.

Parameters:
method - to invoke
object - that has the method
Returns:
value of the invoked method
Throws:
IllegalArgumentException - if the method cannot be invoked

invokeSetterMethod

public static void invokeSetterMethod(Method method,
                                      Object object,
                                      Object value)
Invokes the supplied method on the supplied object with the supplied value as a parameter.

Parameters:
method - to invoke
object - that has the method
value - to set
Throws:
IllegalArgumentException - if the method cannot be invoked


Copyright © 2003-2016 Virginia Tech. All Rights Reserved.