Package org.marketcetera.util.misc
Class ReflectUtils
- java.lang.Object
-
- org.marketcetera.util.misc.ReflectUtils
-
public final class ReflectUtils extends Object
Utilities for reflection.- Since:
- 0.6.0
- Version:
- $Id: ReflectUtils.java 16154 2012-07-14 16:34:05Z colin $
- Author:
- tlerios@marketcetera.com
-
-
Constructor Summary
Constructors Modifier Constructor Description privateReflectUtils()Constructor.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Class<?>[]getAllClasses(Class<?> c)Returns all superclasses and interfaces of the given class, incl.private static voidgetAllClasses(Set<Class<?>> result, Class<?> c)Auguments the given set with all superclasses and interfaces of the given class, incl.static Field[]getAllFields(Class<?> c)Returns all fields of the given class, incl.static ObjectgetInstance(String cName, Class<?>[] paramTypes, Object[] paramValues)Returns an instance of the class by the given name, using its constructor with the given parameter types, and invoked using the given parameters.
-
-
-
Method Detail
-
getAllClasses
private static void getAllClasses(Set<Class<?>> result, Class<?> c)
Auguments the given set with all superclasses and interfaces of the given class, incl. the class itself.- Parameters:
result- The set.c- The class.
-
getAllClasses
public static Class<?>[] getAllClasses(Class<?> c)
Returns all superclasses and interfaces of the given class, incl. the class itself.- Parameters:
c- The class.- Returns:
- The classes and interfaces.
-
getAllFields
public static Field[] getAllFields(Class<?> c)
Returns all fields of the given class, incl. those in the class itself, its superclasses and interfaces.- Parameters:
c- The class.- Returns:
- The fields.
-
getInstance
public static Object getInstance(String cName, Class<?>[] paramTypes, Object[] paramValues) throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException
Returns an instance of the class by the given name, using its constructor with the given parameter types, and invoked using the given parameters. It interrupts the current thread if the constructor throws an interruption exception perExceptUtils.isInterruptException(Throwable).- Parameters:
cName- The class name.paramTypes- The constructor parameter types.paramValues- The constructor parameters.- Returns:
- The instance.
- Throws:
ClassNotFoundException- Thrown if a reflection failure occurs.IllegalAccessException- Thrown if a reflection failure occurs.InstantiationException- Thrown if a reflection failure occurs.NoSuchMethodException- Thrown if a reflection failure occurs.InvocationTargetException- Thrown if a reflection failure occurs.
-
-