public class ReflectionUtils extends Object
Constructor and Description |
---|
ReflectionUtils() |
Modifier and Type | Method and Description |
---|---|
static Field |
getDeclaredField(Class clazz,
String fieldName)
get a declared field from class or super classes
|
static Class |
getPropertyType(Class clazz,
String property)
Gets the type of a property of a class.
|
static Class |
getPropertyType(Object object,
String property)
Gets the type of a property of an object.
|
static Method |
getReadMethod(Class clazz,
String property)
Gets the read method for a property in a class.
|
public static Class getPropertyType(Object object, String property)
object
- The object that the property belongs to, cannot be null.property
- The property to get type, can be nested. for example,
'foo.bar.baz'.public static Class getPropertyType(Class clazz, String property)
clazz
- The class that the property belongs to, cannot be null.property
- The property to get type, can be nested. for example,
'foo.bar.baz'.public static Method getReadMethod(Class clazz, String property)
class Foo {
public String getBar() { return "bar"; }
public Boolean isBaz() { return false; }
}
BeanUtils.getReadMethod(Foo.class, "bar"); // return Foo#getBar()
BeanUtils.getReadMethod(Foo.class, "baz"); // return Foo#isBaz()
BeanUtils.getReadMethod(Foo.class, "baa"); // return null
clazz
- The class to get read method.property
- The property to get read method for, can NOT be nested.Copyright © 2015. All rights reserved.