/** * Returns object property using JavaBean-compatible introspection with one * addition - a property can be a dot-separated property name path. */ public static Object getProperty(Object object, String nestedPropertyName) throws CayenneRuntimeException { return accessor(nestedPropertyName).getValue(object); }
/** * 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. */ public static void setProperty(Object object, String nestedPropertyName, Object value) throws CayenneRuntimeException { accessor(nestedPropertyName).setValue(object, value); }
public static PropertyReader reader(String fixedPropertyName) { Accessor accessor = PropertyUtils.accessor(fixedPropertyName); return (root, name) -> accessor.getValue(root); }