public class BeanUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
GET
prefix used by non-boolean getter methods
|
static String |
IS
prefix used by boolean getter methods
|
static String |
SET
prefix used by setter methods
|
| Constructor and Description |
|---|
BeanUtil() |
| Modifier and Type | Method and Description |
|---|---|
static Method |
getGetterMethod(Class<?> beanClass,
String property)
Returns getter method for
property in specified beanClass |
static Method |
getGetterMethod(Class<?> beanClass,
String property,
Class propertyType)
Returns getter method for
property in specified beanClass |
static String |
getMethodSuffix(String property) |
static <T> T |
getProperty(Object bean,
String property)
Returns the value of the specified
property in given bean |
static String |
getPropertyName(String methodName) |
static Class |
getPropertyType(Class<?> beanClass,
String property)
Returns the type of
property in given beanClass |
static Method |
getSetterMethod(Class<?> beanClass,
String property)
Returns setter method for
property in specified beanClass |
static Method |
getSetterMethod(Class<?> beanClass,
String property,
Class propertyType)
Returns setter method for
property in specified beanClass |
static void |
setProperty(Object bean,
String property,
Object value)
Sets the value of the specified
property in given bean |
public static final String GET
public static final String IS
public static final String SET
public static Method getGetterMethod(Class<?> beanClass, String property)
property in specified beanClassbeanClass - bean classproperty - name of the propertyproperty is not foundgetGetterMethod(Class, String, Class)public static Method getGetterMethod(Class<?> beanClass, String property, Class propertyType)
property in specified beanClassbeanClass - bean classproperty - name of the propertypropertyType - type of the property. This is used to compute getter method name.property is not foundgetGetterMethod(Class, String)public static Method getSetterMethod(Class<?> beanClass, String property)
property in specified beanClassbeanClass - bean classproperty - name of the propertyproperty is not found, or it is readonly propertygetSetterMethod(Class, String, Class)public static Method getSetterMethod(Class<?> beanClass, String property, Class propertyType)
property in specified beanClassbeanClass - bean classproperty - name of the propertypropertyType - type of the property. This is used to compute setter method name.property is not found, or it is readonly propertygetSetterMethod(Class, String)public static Class getPropertyType(Class<?> beanClass, String property)
property in given beanClassbeanClass - bean classproperty - name of the propertypropertypublic static <T> T getProperty(Object bean, String property) throws InvocationTargetException
property in given beanbean - bean objectproperty - property name whose value needs to be returnedInvocationTargetException - if method invocation failsNullPointerException - if property is not found in beanpublic static void setProperty(Object bean, String property, Object value) throws InvocationTargetException
property in given beanbean - bean objectproperty - property name whose value needs to be setvalue - value to be setInvocationTargetException - if method invocation failsNullPointerException - if property is not found in bean or it is readonly propertyCopyright © 2021. All rights reserved.