org.org.usurper.utils
Class ReflectionUtils

java.lang.Object
  extended by org.org.usurper.utils.ReflectionUtils

public final class ReflectionUtils
extends java.lang.Object

This class is a reflection utility class

Author:
pagregoire

Method Summary
static java.lang.reflect.Field getField(java.lang.Object object, java.lang.String attributeName)
          This method gets the Field from an Object and an attribute name.
static java.lang.reflect.Type[] getGenericTypes(java.lang.reflect.Constructor<?> targetConstructor, java.lang.Integer constructorArgOrderingNumber)
          Gets the generic types for a given constructor argument (specified by its ordering number).
static java.lang.reflect.Type[] getGenericTypes(java.lang.reflect.Field attribute)
          Gets the generic types for a given field.
static void setProperty(java.lang.Object object, java.lang.reflect.Method setter, java.lang.Object value)
          This method invokes a property's setter on an object
static void setProperty(java.lang.Object object, java.lang.String propertyName, java.lang.Object value)
          This method sets a property on an object
static java.lang.Class<?> toNotPrimitiveType(java.lang.Class<?> usurpedClass)
          Turns a primitive type to its Object counterpart.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getGenericTypes

public static java.lang.reflect.Type[] getGenericTypes(java.lang.reflect.Constructor<?> targetConstructor,
                                                       java.lang.Integer constructorArgOrderingNumber)
Gets the generic types for a given constructor argument (specified by its ordering number).

Parameters:
targetConstructor - the target constructor
constructorArgOrderingNumber - the constructor arg ordering number
Returns:
the generic types

getGenericTypes

public static java.lang.reflect.Type[] getGenericTypes(java.lang.reflect.Field attribute)
Gets the generic types for a given field.

Parameters:
attribute - the attribute
Returns:
the generic types

getField

public static java.lang.reflect.Field getField(java.lang.Object object,
                                               java.lang.String attributeName)
                                        throws java.lang.SecurityException,
                                               java.lang.NoSuchFieldException
This method gets the Field from an Object and an attribute name.

Parameters:
object -
attributeName -
Returns:
Throws:
java.lang.SecurityException
java.lang.NoSuchFieldException

setProperty

public static void setProperty(java.lang.Object object,
                               java.lang.String propertyName,
                               java.lang.Object value)
                        throws java.lang.SecurityException,
                               java.lang.NoSuchFieldException,
                               java.lang.IllegalArgumentException,
                               java.lang.IllegalAccessException
This method sets a property on an object

Parameters:
object -
propertyName -
value -
Throws:
java.lang.SecurityException
java.lang.NoSuchFieldException
java.lang.IllegalArgumentException
java.lang.IllegalAccessException

setProperty

public static void setProperty(java.lang.Object object,
                               java.lang.reflect.Method setter,
                               java.lang.Object value)
                        throws java.lang.IllegalArgumentException,
                               java.lang.IllegalAccessException,
                               java.lang.reflect.InvocationTargetException
This method invokes a property's setter on an object

Parameters:
object -
propertyDescriptor -
value -
Throws:
java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException
java.lang.IllegalArgumentException

toNotPrimitiveType

public static java.lang.Class<?> toNotPrimitiveType(java.lang.Class<?> usurpedClass)
Turns a primitive type to its Object counterpart.
Just returns the passed type as-is if it is not primitive.

Parameters:
usurpedClass - the usurped class
Returns:
the not primitive type


Copyright © 2008. All Rights Reserved.