Skip to content

Commit

Permalink
One more
Browse files Browse the repository at this point in the history
  • Loading branch information
triceo committed Nov 27, 2024
1 parent 7bf44bf commit 2c382d4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void unsetElement(InnerScoreDirector<Solution_, ?> scoreDirector, Object
}

protected void setValue(InnerScoreDirector<Solution_, ?> scoreDirector, Object element, Object value) {
if (shadowVariableDescriptor.getValue(element) != value) {
if (getElement(element) != value) {
scoreDirector.beforeVariableChanged(shadowVariableDescriptor, element);
shadowVariableDescriptor.setValue(element, value);
scoreDirector.afterVariableChanged(shadowVariableDescriptor, element);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,7 @@ public void addElement(InnerScoreDirector<Solution_, ?> scoreDirector, Object el
}

public void removeElement(InnerScoreDirector<Solution_, ?> scoreDirector, Object element) {
setIndex(scoreDirector, element, null);
}

private void setIndex(InnerScoreDirector<Solution_, ?> scoreDirector, Object element, Object value) {
scoreDirector.beforeVariableChanged(shadowVariableDescriptor, element);
shadowVariableDescriptor.setValue(element, value);
scoreDirector.afterVariableChanged(shadowVariableDescriptor, element);
updateIndex(scoreDirector, element, null);
}

public void unassignElement(InnerScoreDirector<Solution_, ?> scoreDirector, Object element) {
Expand All @@ -36,9 +30,11 @@ public void changeElement(InnerScoreDirector<Solution_, ?> scoreDirector, Object
}

private void updateIndex(InnerScoreDirector<Solution_, ?> scoreDirector, Object element, Integer index) {
var oldIndex = shadowVariableDescriptor.getValue(element);
var oldIndex = getIndex(element);
if (!Objects.equals(oldIndex, index)) {
setIndex(scoreDirector, element, index);
scoreDirector.beforeVariableChanged(shadowVariableDescriptor, element);
shadowVariableDescriptor.setValue(element, index);
scoreDirector.afterVariableChanged(shadowVariableDescriptor, element);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void removeElement(InnerScoreDirector<Solution_, ?> scoreDirector, Object
}

public void unassignElement(InnerScoreDirector<Solution_, ?> scoreDirector, Object element) {
setInverse(scoreDirector, null, element);
changeElement(scoreDirector, null, element);
}

public void changeElement(InnerScoreDirector<Solution_, ?> scoreDirector, Object entity, Object element) {
Expand Down

0 comments on commit 2c382d4

Please sign in to comment.