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;
...
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…