Class BeanUtils
- java.lang.Object
-
- org.vedantatree.expressionoasis.utils.BeanUtils
-
public final class BeanUtils extends Object
This class provides the util methods for bean management. One can handle bean using these util method like method invocation by name property accessing by the name and many more.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static PropertyDescriptorgetPropertyDescriptor(Class beanClass, String property)Gets the property descriptor for the property name from given class.static ClassgetPropertyType(Class beanClass, String property)Gets the return type of property.static ObjectgetPropertyValue(Object bean, String property)Gets the value of property from the bean object.static booleanisPropertyEditable(Class beanClass, String property)Checks whether the property is editable or not.static voidsetPropertyValue(Object bean, String property, Object value)Sets the value of property to the object of bean
-
-
-
Method Detail
-
isPropertyEditable
public static final boolean isPropertyEditable(Class beanClass, String property) throws IntrospectionException
Checks whether the property is editable or not. Generally it checks whether the mutator is available for this property or not. A property is editable iff the property mutator is available.- Parameters:
beanClass- the class of bean whose property is being inspecting.property- the name of property to inspect.- Returns:
- Returns
trueif the property is editable elsefalse - Throws:
IntrospectionException
-
getPropertyType
public static final Class getPropertyType(Class beanClass, String property) throws IntrospectionException
Gets the return type of property.- Parameters:
beanClass- the class of bean whose property is being inspecting.property- the name of property- Returns:
- the type of property. Returns
nullif the property name if not found in bean class. - Throws:
IntrospectionException
-
getPropertyValue
public static final Object getPropertyValue(Object bean, String property) throws IntrospectionException, IllegalArgumentException, IllegalAccessException, InvocationTargetException
Gets the value of property from the bean object.- Parameters:
bean- the object of bean class whose property is to access.property- the name of property.- Returns:
- the value of property.
- Throws:
IntrospectionExceptionIllegalArgumentExceptionIllegalAccessExceptionInvocationTargetException
-
setPropertyValue
public static final void setPropertyValue(Object bean, String property, Object value) throws IntrospectionException, IllegalArgumentException, IllegalAccessException, InvocationTargetException
Sets the value of property to the object of bean- Parameters:
bean- the bean object whose proeprty is to set.property- the name of property.value- the value to set for the property.- Throws:
IntrospectionExceptionIllegalArgumentExceptionIllegalAccessExceptionInvocationTargetException
-
getPropertyDescriptor
public static final PropertyDescriptor getPropertyDescriptor(Class beanClass, String property) throws IntrospectionException
Gets the property descriptor for the property name from given class.- Parameters:
beanClass- the class of beanproperty- the name of property.- Returns:
- the property descriptor if property name found else return
null. - Throws:
IntrospectionException
-
-