public class ReflectionUtils extends Object
| Constructor and Description |
|---|
ReflectionUtils() |
| Modifier and Type | Method and Description |
|---|---|
static Class[] |
createTypeArray(Object[] args)
Generate an array of the types of the specified arguments.
|
static Object |
deepCopy(Object o)
Perform a deep copy of an object.
|
static String |
dumpObject(Object o,
String... names)
Generates a string that displays all return values for all getters of an object.
|
static String |
dumpObject(Object o,
String separator,
boolean displaySimpleClassName,
boolean displayHashCode,
String... names)
Generates a string that displays all return values for all getters of an object.
|
static Method[] |
getAllBeanMethods(Class clazz,
boolean getters)
Obtain all the getters or setters of a specified class.
|
static String |
getCurrentMethodName()
Get the name of the method that called this one.
|
static Method |
getGetter(Class clazz,
String name)
Get a getter with a given name from a class.
|
static Method |
getGetterForAttribute(Class clazz,
String attrName)
Get a getter corresponding to a specified instance variable name from a class.
|
static AnnotatedElement |
getJPPFAnnotatedElement(Class<?> clazz)
Determines whether a class has a JPPF-annotated method and can be executed as a task.
|
static Constructor |
getMatchingConstructor(Class clazz,
Object[] args)
Get the constructor with in the specified declaring class, that matches
the number, order and types of the specified arguments.
|
static Method |
getMatchingMethod(Class clazz,
String name,
Object[] args)
Get the method with the specified name, in the specified declaring class, that matches
the number, order and types of the specified arguments.
|
static Method |
getSetter(Class clazz,
String name)
Get a setter with a given name from a class.
|
static Method |
getSetterForAttribute(Class clazz,
String attrName)
Get a setter corresponding to a specified instance variable name from a class.
|
static boolean |
isGetter(Method meth)
Determines whether a method is a getter (accessor), according to Sun's naming conventions.
|
static boolean |
isJPPFAnnotated(AnnotatedElement annotatedElement)
Determines whether a method is JPPF-annotated and can be executed as a task.
|
static boolean |
isJPPFAnnotated(Class<?> clazz)
Determines whether a class has a JPPF-annotated method and can be executed as a task.
|
static boolean |
isSetter(Method meth)
Determines whether a method is a setter (mutator), according to Sun's naming conventions.
|
static Class |
mapPrimitveType(Class type)
Map a primitive type to its corresponding wrapper type.
|
static boolean |
matchingTypes(Class<?>[] argTypes,
Class<?>[] types)
Determine whether a set of (possibly null) types loosely matches another set of types.
|
public static String dumpObject(Object o, String... names)
o - the object whose getter return values are to be dumped into a string.names - the names of the attributes to dump. If null or empty, then all attributes that have a getter, except "class", are dumped.
This parameter is used as a filter on the attributes to dump and defines the order in which the fields are dumped.public static String dumpObject(Object o, String separator, boolean displaySimpleClassName, boolean displayHashCode, String... names)
o - the object whose getter return values are to be dumped into a string.separator - separator between field values, like a comma or a new line.displaySimpleClassName - true to use the object's class simple name, false for the fully qualified name.displayHashCode - whether to append '@hashcode_value' to the name of the class.names - the names of the attributes to dump. If null or empty, then all attributes that have a getter, except "class", are dumped.
This parameter is used as a filter on the attributes to dump and defines the order in which the fields are dumped.public static boolean isGetter(Method meth)
meth - the method to analyse.public static boolean isSetter(Method meth)
meth - the method to analyse.public static Method getGetter(Class clazz, String name)
clazz - the class enclosing the getter.name - the name of the getter to look for.Method object, or null if the class has no getter with the specified name.public static Method getSetter(Class clazz, String name)
clazz - the class enclosing the setter.name - the name of the setter to look for.Method object, or null if the class has no setter with the specified name.public static Method getGetterForAttribute(Class clazz, String attrName)
clazz - the class enclosing the instance variable.attrName - the name of the instance variable to look for.Method object, or null if the class has no getter for the specified
instance variable name.public static Method getSetterForAttribute(Class clazz, String attrName)
clazz - the class enclosing the instance variable.attrName - the name of the instance variable to look for.Method object, or null if the class has no setter for the specified
instance variable name.public static Method[] getAllBeanMethods(Class clazz, boolean getters)
clazz - the class to get the methods from.getters - if true, indicates that the getters should be looked up, otherwise it should be the setters.Method instances.public static Object deepCopy(Object o)
o - the object to copy.public static boolean isJPPFAnnotated(Class<?> clazz)
clazz - the class to check.public static AnnotatedElement getJPPFAnnotatedElement(Class<?> clazz)
clazz - the class to check.public static boolean isJPPFAnnotated(AnnotatedElement annotatedElement)
annotatedElement - the method to check.public static Method getMatchingMethod(Class clazz, String name, Object[] args)
clazz - the class in which to look for the method.name - the name of the method to look for.args - the arguments of the method.Method instance, or null if no match could be found.public static Constructor getMatchingConstructor(Class clazz, Object[] args)
clazz - the class in which to look for the constructor.args - the arguments of the method.Constructor instance, or null if no match could be found.public static boolean matchingTypes(Class<?>[] argTypes, Class<?>[] types)
argTypes - the types to match, null values are considered wildcards (matching any type).types - the set of types to match.public static Class mapPrimitveType(Class type)
type - a primitive type.Class instance.public static Class[] createTypeArray(Object[] args)
args - the arguments to get the types from.Class instances.public static String getCurrentMethodName()
Copyright © 2005-2012 JPPF Team.