Package adams.core.discovery
Class PropertyPath
- java.lang.Object
-
- adams.core.discovery.PropertyPath
-
public class PropertyPath extends Object
A helper class for accessing properties in nested objects, e.g., accessing the "getRidge" method of a LinearRegression classifier part of MultipleClassifierCombiner, e.g., Vote. For doing so, one needs to supply the object to work on and a property path. The property path is a dot delimited path of property names ("getFoo()" and "setFoo(int)" have "foo" as property name), indices of arrays are 0-based. E.g.:
getPropertyDescriptor(vote, "classifiers[1].ridge")will return the second classifier (which should be our LinearRegression) of the given Vote meta-classifier and there the property descriptor of the "ridge" property.getValue(...)will return the actual value of the ridge parameter andsetValue(...)will set it.
Using.get(X)it is possible to access the items ofListobjects, with "X" being the index for the "get(index)" method.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPropertyPath.PathContains a (property) path structure.static classPropertyPath.PathElementRepresents a single element of a property path.static classPropertyPath.PathElementTypeThe type of path element we're dealing with.static classPropertyPath.PropertyContainerA helper class that stores Object and PropertyDescriptor together.
-
Constructor Summary
Constructors Constructor Description PropertyPath()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static PropertyPath.PropertyContainerfind(Object src, PropertyPath.Path current, PropertyPath.Path full, MessageCollection errors)returns the property and object associated with the given path, null if a problem occurred.static PropertyPath.PropertyContainerfind(Object src, PropertyPath.Path path, MessageCollection errors)returns the property and object associated with the given path, null if a problem occurred.static PropertyPath.PropertyContainerfind(Object src, String path, MessageCollection errors)returns the property and object associated with the given path, null if a problem occurred.static ObjectgetValue(Object src, PropertyPath.Path path, MessageCollection errors)returns the value specified by the given path from the object.static ObjectgetValue(Object src, String path, MessageCollection errors)returns the value specified by the given path from the object.static voidmain(String[] args)for testing only.static booleansetValue(Object src, PropertyPath.Path path, Object value, MessageCollection errors)set the given value specified by the given path in the object.static booleansetValue(Object src, String path, Object value, MessageCollection errors)set the given value specified by the given path in the object.
-
-
-
Method Detail
-
find
public static PropertyPath.PropertyContainer find(Object src, String path, MessageCollection errors)
returns the property and object associated with the given path, null if a problem occurred.- Parameters:
src- the object to start frompath- the path to follow- Returns:
- not null, if the property could be found
-
find
public static PropertyPath.PropertyContainer find(Object src, PropertyPath.Path path, MessageCollection errors)
returns the property and object associated with the given path, null if a problem occurred.- Parameters:
src- the object to start frompath- the path to follow- Returns:
- not null, if the property could be found
-
find
protected static PropertyPath.PropertyContainer find(Object src, PropertyPath.Path current, PropertyPath.Path full, MessageCollection errors)
returns the property and object associated with the given path, null if a problem occurred.- Parameters:
src- the object to start fromcurrent- the path to followfull- the full path- Returns:
- not null, if the property could be found
-
getValue
public static Object getValue(Object src, PropertyPath.Path path, MessageCollection errors)
returns the value specified by the given path from the object.- Parameters:
src- the object to work onpath- the retrieval path- Returns:
- the value, null if an error occurred
-
getValue
public static Object getValue(Object src, String path, MessageCollection errors)
returns the value specified by the given path from the object.- Parameters:
src- the object to work onpath- the retrieval path- Returns:
- the value, null if an error occurred
-
setValue
public static boolean setValue(Object src, PropertyPath.Path path, Object value, MessageCollection errors)
set the given value specified by the given path in the object.- Parameters:
src- the object to work onpath- the retrieval pathvalue- the value to set- Returns:
- true if the value could be set
-
setValue
public static boolean setValue(Object src, String path, Object value, MessageCollection errors)
set the given value specified by the given path in the object.- Parameters:
src- the object to work onpath- the retrieval pathvalue- the value to set- Returns:
- true if succesfully set
-
-