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 MethodfindGetter(Class<?> klass, String property) Finds a getter method for a property.static MethodfindSetter(Class<?> klass, String property) Finds a setter method for a property.static ObjectGets a property value from a bean.static ObjectgetFieldChecked(Object obj, String property) Gets a property value from a bean.static voidregisterConverter(Class<?> type, UnaryOperator<Object> converter) static voidSets a property value on a bean.static voidsetFieldChecked(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:
NoSuchMethodExceptionIllegalAccessExceptionInvocationTargetException
-
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:
NoSuchMethodExceptionIllegalAccessExceptionInvocationTargetException
-
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
-