Uploaded image for project: 'OptaPlanner'
  1. OptaPlanner
  2. PLANNER-909

Implement equals/hashCode in ConstraintMatch, ConstraintMatchTotal and Indictment (for usage in Map, Set, etc)

XMLWordPrintable

    • Icon: Feature Request Feature Request
    • Resolution: Done
    • Icon: Optional Optional
    • 7.5.0.Final
    • 7.3.0.Final
    • optaplanner-core
    • None
    • NEW
    • NEW

      While implementing a ConstraintMatchAwareIncrementalScoreCalculator I noticed, that the removeConstraintMatch method in ConstraintMatchTotal is not working correctly, as there is no hashCode implementation for ConstraintMatch.
      I am trying to use the ConstraintMatchTotal.getScore method to return the score in the calculateScore method, but it fails, since the beforeVariableChanged method cannot remove the respective ConstraintMatch.
      Also, as it is today, the compareTo method of ConstraintMatch is not consistent with the equals method, thus it breaks the compareTo contract.
      (I have modified OptaPlanner to include the equals and hashCode methods - consistent with compareTo - and it is working fine.)

              gdesmet@redhat.com Geoffrey De Smet (Inactive)
              trks1970_jira Tibor Kiss (Inactive)
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: