Package com.axelor.app.settings
Class BeanConfigurator
java.lang.Object
com.axelor.app.settings.BeanConfigurator
Bean configurator using reflection
This provides utility methods for dynamically accessing and modifying bean properties using reflection. It can convert values that typically come from configuration files to the appropriate types for property assignment.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Method
findGetter
(Class<?> klass, String property) Finds a getter method for a property.static Method
findSetter
(Class<?> klass, String property) Finds a setter method for a property.static Object
Gets a property value from a bean.static Object
getFieldChecked
(Object obj, String property) Gets a property value from a bean.static void
registerConverter
(Class<?> type, UnaryOperator<Object> converter) static void
Sets a property value on a bean.static void
setFieldChecked
(Object obj, String property, Object value) Sets a property value on a bean.
-
Method Details
-
getField
Gets a property value from a bean.- Parameters:
obj
- the beanproperty
- the property name- Returns:
- the property value
-
getFieldChecked
public static Object getFieldChecked(Object obj, String property) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException Gets a property value from a bean.This can throw a checked
ReflectiveOperationException
.- Parameters:
obj
- the beanproperty
- the property name- Returns:
- the property value
- Throws:
NoSuchMethodException
IllegalAccessException
InvocationTargetException
-
setField
Sets a property value on a bean.- Parameters:
obj
- the beanproperty
- the property namevalue
- the property value
-
setFieldChecked
public static void setFieldChecked(Object obj, String property, Object value) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException Sets a property value on a bean.This can throw a checked
ReflectiveOperationException
.- Parameters:
obj
- the beanproperty
- the property namevalue
- the property value- Throws:
NoSuchMethodException
IllegalAccessException
InvocationTargetException
-
findGetter
Finds a getter method for a property.- Parameters:
klass
- the class to searchproperty
- the property name- Returns:
- the getter method
- Throws:
NoSuchMethodException
-
findSetter
Finds a setter method for a property.- Parameters:
klass
- the class to searchproperty
- the property name- Returns:
- the setter method
- Throws:
NoSuchMethodException
-
registerConverter
-