Package bitronix.tm.utils
Class PropertyUtils
java.lang.Object
bitronix.tm.utils.PropertyUtils
Smart reflection helper.
- Author:
- lorban
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic MapgetProperties(Object target) Build a map of direct javabeans properties of the target object.static ObjectgetProperty(Object target, String propertyName) Get a direct or indirect property (dotted property: prop1.prop2.prop3) on the target object.static StringpropertiesToString(Object obj) Return a comma-separated String of r/w properties of the specified object.static voidsetProperties(Object target, Map properties) Set aMapof direct or indirect properties on the target object.static voidsetProperty(Object target, String propertyName, Object propertyValue) Set a direct or indirect property (dotted property: prop1.prop2.prop3) on the target object.
-
Constructor Details
-
PropertyUtils
public PropertyUtils()
-
-
Method Details
-
setProperty
public static void setProperty(Object target, String propertyName, Object propertyValue) throws PropertyException Set a direct or indirect property (dotted property: prop1.prop2.prop3) on the target object. This method tries to be smart in the way that intermediate properties currently set to null are set if it is possible to create and set an object. Conversions from propertyValue to the proper destination type are performed when possible.- Parameters:
target- the target object on which to set the property.propertyName- the name of the property to set.propertyValue- the value of the property to set.- Throws:
PropertyException- if an error happened while trying to set the property.
-
getProperties
Build a map of direct javabeans properties of the target object. Only read/write properties (ie: those who have both a getter and a setter) are returned.- Parameters:
target- the target object from which to get properties names.- Returns:
- a Map of String with properties names as key and their values
- Throws:
PropertyException- if an error happened while trying to get a property.
-
getProperty
Get a direct or indirect property (dotted property: prop1.prop2.prop3) on the target object.- Parameters:
target- the target object from which to get the property.propertyName- the name of the property to get.- Returns:
- the value of the specified property.
- Throws:
PropertyException- if an error happened while trying to get the property.
-
setProperties
Set aMapof direct or indirect properties on the target object.- Parameters:
target- the target object on which to set the properties.properties- aMapof String/Object pairs.- Throws:
PropertyException- if an error happened while trying to set a property.
-
propertiesToString
Return a comma-separated String of r/w properties of the specified object.- Parameters:
obj- the object to introspect.- Returns:
- a a comma-separated String of r/w properties.
-