public class ClassUtil extends Object
| Constructor and Description |
|---|
ClassUtil() |
| Modifier and Type | Method and Description |
|---|---|
static Object |
findEnumConstant(Class<?> type,
String constantName)
Finds an instance of an Enum constant on a class.
|
static Object |
findEnumConstant(Class<?> type,
String constantName,
boolean caseSensitive)
Finds an instance of an Enum constant on a class.
|
static Method[] |
getBeanMethods(Class<?> type,
String propertyName,
Class<?> propertyType,
boolean caseSensitive)
Gets the methods within this class that implements public "bean" methods
(get and set) for the property name.
|
static Class<?>[] |
getClassHierarchy(Class<?> type)
Returns an array of class objects representing the entire class hierarchy
with the most-super class as the first element followed by all subclasses
in the order they are declared.
|
static Method |
getMethod(Class<?> type,
String name,
Class<?> returnType,
Class<?> paramType,
boolean caseSensitive)
Gets the public method within the type that matches the method name, return type,
and single parameter type.
|
static boolean |
hasBeanMethods(Class<?> type,
String propertyName,
Class<?> propertyType,
boolean caseSensitive)
Checks if the class implements public "bean" methods (get and set) for the
name.
|
public static Object findEnumConstant(Class<?> type, String constantName)
public static Object findEnumConstant(Class<?> type, String constantName, boolean caseSensitive)
public static Class<?>[] getClassHierarchy(Class<?> type)
public static boolean hasBeanMethods(Class<?> type, String propertyName, Class<?> propertyType, boolean caseSensitive)
type - The class to searchpropertyName - The property name to search for, if "firstName", then
this method will internally add the "get" and "set" to the beginning.propertyType - The class type of the propertycaseSensitive - If the search is case sensitive or notpublic static Method[] getBeanMethods(Class<?> type, String propertyName, Class<?> propertyType, boolean caseSensitive) throws IllegalAccessException, NoSuchMethodException
type - The class to searchpropertyName - The name to search forparamType - The class type of the propertycaseSensitive - If the search is case sensitive or notIllegalAccessException - If the method was found, but is not public.NoSuchMethodException - If the method was not foundpublic static Method getMethod(Class<?> type, String name, Class<?> returnType, Class<?> paramType, boolean caseSensitive) throws IllegalAccessException, NoSuchMethodException
type - The class to search for the methodname - The name of the method to search forreturnType - The expected return type or null if its expected to be a void methodparamType - The expected parameter type or null if no parameters are expectedcaseSensitive - True if its a case sensitive search, otherwise falseIllegalAccessException - If the method was found, but is not public.NoSuchMethodException - If the method was not foundCopyright © 2012-2015 Cloudhopper by Twitter. All Rights Reserved.