Package org.apache.cayenne.reflect
Class PropertyUtils
java.lang.Object
org.apache.cayenne.reflect.PropertyUtils
Utility methods to quickly access object properties. This class supports
 simple and nested properties and also conversion of property values to match
 property type. No converter customization is provided yet, so only basic
 converters for Strings, Numbers and primitives are available.
- Since:
- 1.2
- 
Method SummaryModifier and TypeMethodDescriptionstatic AccessorCompiles an accessor that can be used for fast access for the nested property of the objects of a given class.static Accessoraccessor(CayennePath nestedPropertyPath) Compiles an accessor that can be used for fast access for the nested property of the objects of a given class.static ObjectgetProperty(Object object, String nestedPropertyName) Returns object property using JavaBean-compatible introspection with one addition - a property can be a dot-separated property name path.static ObjectgetProperty(Object object, CayennePath nestedProperty) Returns object property using JavaBean-compatible introspection with one addition - a property can be a dot-separated property name path.static voidinstallAccessorFactory(AccessorFactory accessorFactory) This method installs custom accessor factory to be used by property utils.static voidsetProperty(Object object, String nestedPropertyName, Object value) Sets object property using JavaBean-compatible introspection with one addition - a property can be a dot-separated property name path.
- 
Method Details- 
accessorCompiles an accessor that can be used for fast access for the nested property of the objects of a given class.- Since:
- 4.0
 
- 
accessorCompiles an accessor that can be used for fast access for the nested property of the objects of a given class.- Parameters:
- nestedPropertyPath- path value for the property
- Returns:
- Accessorfor the property
- Since:
- 5.0
 
- 
getPropertypublic static Object getProperty(Object object, String nestedPropertyName) throws CayenneRuntimeException Returns object property using JavaBean-compatible introspection with one addition - a property can be a dot-separated property name path.- Throws:
- CayenneRuntimeException
 
- 
getPropertypublic static Object getProperty(Object object, CayennePath nestedProperty) throws CayenneRuntimeException Returns object property using JavaBean-compatible introspection with one addition - a property can be a dot-separated property name path.- Throws:
- CayenneRuntimeException
 
- 
setPropertypublic static void setProperty(Object object, String nestedPropertyName, Object value) throws CayenneRuntimeException Sets object property using JavaBean-compatible introspection with one addition - a property can be a dot-separated property name path. Before setting a value attempts to convert it to a type compatible with the object property. Automatic conversion is supported between strings and basic types like numbers or primitives.- Throws:
- CayenneRuntimeException
 
- 
installAccessorFactoryThis method installs custom accessor factory to be used by property utils.A factory that produces BeanAccessoris used by default.- Parameters:
- accessorFactory- new factory to use
- Since:
- 4.1
 
 
-