public class ReflectionUtils extends Object
Modifier and Type | Field and Description |
---|---|
static String |
ARRAYS_DELIMITER |
Constructor and Description |
---|
ReflectionUtils() |
Modifier and Type | Method and Description |
---|---|
static List<Field> |
getClassFields(Class clazz,
Class type,
boolean isStatic,
String[] fieldsToIgnore) |
static List<Field> |
getClassHierarchyFields(Class clazz,
Class fieldType,
boolean isStatic,
String[] fieldsToIgnore) |
static Class[] |
getClassHierarchyInterfaces(Class clazz) |
static Field |
getField(Object obj,
String propertyName) |
static String |
getGetMethodName(String fieldName)
Generates the name of a get method for the given field name.
|
static Method |
getGetter(Object obj,
String propertyName) |
static Object |
getPrivateField(Object o,
String fieldName) |
static String |
getSetMethodName(String fieldName)
Generates the name of a create method for the given field name.
|
static Method |
getSetter(Object obj,
Method getter,
String propertyName) |
static Object |
invokeMethod(Object o,
String methodName,
Object[] params) |
static boolean |
isGetMethod(Method method)
Checks if the given method is a get method.
|
static boolean |
isIsMethod(Method method)
Checks if the given method is a 'is' method.
|
static boolean |
isSetMethod(Method method)
Checks if the given method is a set method.
|
static void |
main(String[] args) |
static <T> T |
newInstanceForClass(Class<T> type) |
static Object |
parseAndSetFieldValue(Object obj,
String fieldName,
String fieldValue) |
static Object |
parseAndSetFieldValues(Object obj,
String fieldName,
String[] fieldValues) |
static <T> T |
parseValue(String value,
Class<T> type) |
static Object |
setFieldFile(Object obj,
String fieldName,
File fieldValue) |
static Object |
setFieldValue(Object obj,
String fieldName,
Object fieldValue) |
static Object[] |
toArray(String value,
Class type) |
static boolean |
toBoolean(String parameter) |
static byte |
toByte(String parameter) |
static byte[] |
toByteArray(File f) |
static char |
toChar(String parameter) |
static double |
toDouble(String parameter) |
static Object |
toFile(String paramValue) |
static float |
toFloat(String parameter) |
static int |
toInt(String parameter) |
static long |
toLong(String parameter) |
static short |
toShort(String parameter) |
public static final String ARRAYS_DELIMITER
public static List<Field> getClassHierarchyFields(Class clazz, Class fieldType, boolean isStatic, String[] fieldsToIgnore)
public static List<Field> getClassFields(Class clazz, Class type, boolean isStatic, String[] fieldsToIgnore)
public static final String getGetMethodName(String fieldName)
fieldName
- the field name to generate a method name forpublic static final String getSetMethodName(String fieldName)
fieldName
- the field name to generate a method name forpublic static final boolean isSetMethod(Method method)
method
- the Method to checkpublic static final boolean isGetMethod(Method method)
method
- the Method to checkpublic static final boolean isIsMethod(Method method)
method
- the Method to checkpublic static Object parseAndSetFieldValues(Object obj, String fieldName, String[] fieldValues) throws Exception
Exception
public static Object parseAndSetFieldValue(Object obj, String fieldName, String fieldValue) throws Exception
Exception
public static Object setFieldValue(Object obj, String fieldName, Object fieldValue) throws Exception
Exception
public static Object setFieldFile(Object obj, String fieldName, File fieldValue) throws Exception
Exception
public static <T> T newInstanceForClass(Class<T> type)
public static <T> T parseValue(String value, Class<T> type) throws Exception
Exception
public static byte[] toByteArray(File f) throws IOException
IOException
public static void main(String[] args)
Copyright © 2012–2017 JBoss by Red Hat. All rights reserved.