I am making an application that uses Drools planner.
The @ValueRangeFromSolutionProperty is supposed to refer to a property from another class (NQueens in this case). From the JavaDocs for @ValueRangeFromSolutionProperty:
propertyName
The property name of which exists a getter on the Solution that returns a Collection.
But I noticed an inconsistency: the annotator uses the property rowList from NQueens. But rowList (as opposed to RowList) is a private variable (see snippets below). If it were supposed to infer a property by introspection (from it's getter and setter methods), shouldnt it be spelled RowList as in getRowList()?
Question: How does Java infer (introspect) the property name (case and all) from the getter methods?
Or does the @ValueRangeFromSolutionProperty access the private variables directly?
Background details:
From Queen.java, a class that represents a queen on a chessboard:
public class Queen extends AbstractPersistable {
....
@ValueRangeFromSolutionProperty(propertyName = "rowList")
public Row getRow() {
return row;
....
From NQueens.java, the class from which the @ValueRangeFromSolutionProperty gets it's property from:
public class NQueens extends AbstractPersistable implements Solution<SimpleScore> {
...
private List<Column> columnList;
private List<Row> rowList;
....
public List<Row> getRowList() {
return rowList;
...
The JavaBeans Specification says that for a property
propertyNamethere should be a getter methodgetPropertyName()and/or a setter methodsetPropertyName().A property is defined by the only presence of the getter and setter methods and can also be a computed value. A instance variable on the object is not required.
The specification defines the capitalization rules for properties and getter/setter methods:
The method is in fact implemented as:
So:
nameis null, return it as suchnamehas first two characters in caps, return it as such