timefold-solver
timefold-solver copied to clipboard
Shadow Variable listeners called alphabetically instead of in order of declaration
Describe the bug When you have more than 1 Shadowvariable listeners on a variable, they are called alphabetically based on the source variable name.
Expected behavior They are called in the order of declaration
Actual behavior Describe clearly and concisely what actually happened.
To Reproduce Taken from the food-packaging quickstart, this is the original
@InverseRelationShadowVariable(sourceVariableName = "jobList")
private Line line;
@PreviousElementShadowVariable(sourceVariableName = "jobList")
private Job previousJob;
@ShadowVariable(variableListenerClass = StartDateTimeUpdatingVariableListener.class, sourceVariableName = "line")
@ShadowVariable(variableListenerClass = StartDateTimeUpdatingVariableListener.class, sourceVariableName = "previousJob")
private LocalDateTime startCleaningDateTime;
When you change it to e.g.
@InverseRelationShadowVariable(sourceVariableName = "jobList")
private Line technician;
@PreviousElementShadowVariable(sourceVariableName = "jobList")
private Job previousJob;
@ShadowVariable(variableListenerClass = StartDateTimeUpdatingVariableListener.class, sourceVariableName = "technician")
@ShadowVariable(variableListenerClass = StartDateTimeUpdatingVariableListener.class, sourceVariableName = "previousJob")
private LocalDateTime startCleaningDateTime;
You will notice that the variable listener is called in another order (because technician comes alphabetically after `previousJob``
@ge0ffrey has an idea why it happens
Environment
Timefold Solver Version or Git ref:
Output of java -version:
Output of uname -a or ver:
Additional information
Related issue in quickstarts: https://github.com/TimefoldAI/timefold-quickstarts/issues/315