org.granite.util
Class Reflections

java.lang.Object
  extended by org.granite.util.Reflections

public class Reflections
extends Object

Reflections class copied from JBoss Seam. www.seamframework.org jboss-seam-2.0.0.GA Author unattributed


Constructor Summary
Reflections()
           
 
Method Summary
static Class<?> classForName(String name)
           
static Object get(Field field, Object target)
           
static Object getAndWrap(Field field, Object target)
           
static Class<?> getCollectionElementType(Type collectionType)
           
static Field getField(Class<?> clazz, String name)
           
static List<Field> getFields(Class<?> clazz, Class<? extends Annotation> annotation)
          Get all the fields which are annotated with the given annotation.
static Method getGetterMethod(Class<?> clazz, String name)
           
static List<Method> getGetterMethods(Class<?> clazz, Class<? extends Annotation> annotation)
          Get all the getter methods annotated with the given annotation.
static Class<?> getMapKeyType(Type collectionType)
           
static Method getMethod(Annotation annotation, String name)
           
static Method getSetterMethod(Class<?> clazz, String name)
           
static Object invoke(Method method, Object target, Object... args)
           
static Object invokeAndWrap(Method method, Object target, Object... args)
           
static boolean isClassAvailable(String name)
          Return's true if the class can be loaded using Reflections.classForName()
static boolean isInstanceOf(Class<?> clazz, String name)
           
static void set(Field field, Object target, Object value)
           
static void setAndWrap(Field field, Object target, Object value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Reflections

public Reflections()
Method Detail

invoke

public static Object invoke(Method method,
                            Object target,
                            Object... args)
                     throws Exception
Throws:
Exception

get

public static Object get(Field field,
                         Object target)
                  throws Exception
Throws:
Exception

set

public static void set(Field field,
                       Object target,
                       Object value)
                throws Exception
Throws:
Exception

getAndWrap

public static Object getAndWrap(Field field,
                                Object target)

setAndWrap

public static void setAndWrap(Field field,
                              Object target,
                              Object value)

invokeAndWrap

public static Object invokeAndWrap(Method method,
                                   Object target,
                                   Object... args)

classForName

public static Class<?> classForName(String name)
                             throws ClassNotFoundException
Throws:
ClassNotFoundException

isClassAvailable

public static boolean isClassAvailable(String name)
Return's true if the class can be loaded using Reflections.classForName()


getCollectionElementType

public static Class<?> getCollectionElementType(Type collectionType)

getMapKeyType

public static Class<?> getMapKeyType(Type collectionType)

getSetterMethod

public static Method getSetterMethod(Class<?> clazz,
                                     String name)

getGetterMethod

public static Method getGetterMethod(Class<?> clazz,
                                     String name)

getGetterMethods

public static List<Method> getGetterMethods(Class<?> clazz,
                                            Class<? extends Annotation> annotation)
Get all the getter methods annotated with the given annotation. Returns an empty list if none are found


getField

public static Field getField(Class<?> clazz,
                             String name)

getFields

public static List<Field> getFields(Class<?> clazz,
                                    Class<? extends Annotation> annotation)
Get all the fields which are annotated with the given annotation. Returns an empty list if none are found


getMethod

public static Method getMethod(Annotation annotation,
                               String name)

isInstanceOf

public static boolean isInstanceOf(Class<?> clazz,
                                   String name)