org.jboss.weld.environment.servlet.util
Class Reflections

java.lang.Object
  extended by org.jboss.weld.environment.servlet.util.Reflections

public abstract class Reflections
extends Object

Reflection utilities

Author:
Pete Muir

Method Summary
static
<T> Class<T>
classForName(String name)
           
static Field findDeclaredField(Class<?> clazz, String name)
          Search the class hierarchy for a field with the given name.
static Method findDeclaredMethod(Class<?> clazz, String name, Class<?>... args)
          Search the class hierarchy for a method with the given name and arguments.
static ClassLoader getClassLoader()
           
static
<T> T
getFieldValue(Field field, Object instance, Class<T> expectedType)
           
static
<T> T
invokeMethod(Method method, Class<T> expectedReturnType, Object instance, Object... args)
           
static
<T> T
newInstance(String className)
           
static void setFieldValue(Field field, Object instance, Object value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newInstance

public static <T> T newInstance(String className)

classForName

public static <T> Class<T> classForName(String name)

findDeclaredMethod

public static Method findDeclaredMethod(Class<?> clazz,
                                        String name,
                                        Class<?>... args)
Search the class hierarchy for a method with the given name and arguments. Will return the nearest match, starting with the class specified and searching up the hierarchy.

Parameters:
clazz - The class to search
name - The name of the method to search for
args - The arguments of the method to search for
Returns:
The method found, or null if no method is found

findDeclaredField

public static Field findDeclaredField(Class<?> clazz,
                                      String name)
Search the class hierarchy for a field with the given name. Will return the nearest match, starting with the class specified and searching up the hierarchy.

Parameters:
clazz - The class to search
name - The name of the field to search for
Returns:
The field found, or null if no field is found

invokeMethod

public static <T> T invokeMethod(Method method,
                                 Class<T> expectedReturnType,
                                 Object instance,
                                 Object... args)

setFieldValue

public static void setFieldValue(Field field,
                                 Object instance,
                                 Object value)

getFieldValue

public static <T> T getFieldValue(Field field,
                                  Object instance,
                                  Class<T> expectedType)

getClassLoader

public static ClassLoader getClassLoader()


Copyright © 2013 Seam Framework. All Rights Reserved.