Class SingletonListInverseVariableListener<Solution_>

java.lang.Object
org.optaplanner.core.impl.domain.variable.inverserelation.SingletonListInverseVariableListener<Solution_>
All Implemented Interfaces:
Closeable, AutoCloseable, AbstractVariableListener<Solution_,Object>, ListVariableListener<Solution_,Object,Object>, SingletonInverseVariableSupply, Supply

public class SingletonListInverseVariableListener<Solution_> extends Object implements ListVariableListener<Solution_,Object,Object>, SingletonInverseVariableSupply
  • Field Details

  • Constructor Details

  • Method Details

    • beforeEntityAdded

      public void beforeEntityAdded(ScoreDirector<Solution_> scoreDirector, Object entity)
      Specified by:
      beforeEntityAdded in interface AbstractVariableListener<Solution_,Object>
      Parameters:
      scoreDirector - never null
      entity - never null
    • afterEntityAdded

      public void afterEntityAdded(ScoreDirector<Solution_> scoreDirector, Object entity)
      Specified by:
      afterEntityAdded in interface AbstractVariableListener<Solution_,Object>
      Parameters:
      scoreDirector - never null
      entity - never null
    • beforeEntityRemoved

      public void beforeEntityRemoved(ScoreDirector<Solution_> scoreDirector, Object entity)
      Specified by:
      beforeEntityRemoved in interface AbstractVariableListener<Solution_,Object>
      Parameters:
      scoreDirector - never null
      entity - never null
    • afterEntityRemoved

      public void afterEntityRemoved(ScoreDirector<Solution_> scoreDirector, Object entity)
      Specified by:
      afterEntityRemoved in interface AbstractVariableListener<Solution_,Object>
      Parameters:
      scoreDirector - never null
      entity - never null
    • afterListVariableElementUnassigned

      public void afterListVariableElementUnassigned(ScoreDirector<Solution_> scoreDirector, Object element)
      Description copied from interface: ListVariableListener
      The listener must unset all shadow variables it is responsible for when an element is unassigned from the source list variable. For example, a Task's startTime shadow variable must be reset to null after a task is unassigned from Employee.tasks when the move that assigned it there is undone during Construction Heuristic phase.
      Specified by:
      afterListVariableElementUnassigned in interface ListVariableListener<Solution_,Object,Object>
      Parameters:
      scoreDirector - score director
      element - the unassigned element
    • beforeListVariableChanged

      public void beforeListVariableChanged(ScoreDirector<Solution_> scoreDirector, Object entity, int fromIndex, int toIndex)
      Description copied from interface: ListVariableListener
      Tells the listener that some elements within the range starting at fromIndex (inclusive) and ending at toIndex (exclusive) will change. Be aware that the ListVariableListener.afterListVariableChanged(org.optaplanner.core.api.score.director.ScoreDirector<Solution_>, Entity_, int, int) call after the change is done often has a different fromIndex and toIndex because the number of elements in the list variable can change.

      The list variable change includes:

      • Changing position (index) of one or more elements.
      • Removing one or more elements from the list variable.
      • Adding one or more elements to the list variable.
      • Any mix of the above.
      • The range has the following properties:
    • fromIndex is greater than or equal to 0; toIndex is less than or equal to the list variable size.
    • toIndex is greater than or equal to fromIndex.
    • The range contains all elements that are going to be changed.
    • The range may contain elements that are not going to be changed.
    • The range may be empty (fromIndex equals toIndex) if none of the existing list variable elements are going to be changed.
    • Specified by:
      beforeListVariableChanged in interface ListVariableListener<Solution_,Object,Object>
      Parameters:
      scoreDirector - score director
      entity - entity with the changed list variable
      fromIndex - low endpoint (inclusive) of the changed range
      toIndex - high endpoint (exclusive) of the changed range
    • afterListVariableChanged

      public void afterListVariableChanged(ScoreDirector<Solution_> scoreDirector, Object entity, int fromIndex, int toIndex)
      Description copied from interface: ListVariableListener
      Tells the listener that some elements within the range starting at fromIndex (inclusive) and ending at toIndex (exclusive) changed.

      The list variable change includes:

      • Changing position (index) of one or more elements.
      • Removing one or more elements from the list variable.
      • Adding one or more elements to the list variable.
      • Any mix of the above.
      • The range has the following properties:
    • fromIndex is greater than or equal to 0; toIndex is less than or equal to the list variable size.
    • toIndex is greater than or equal to fromIndex.
    • The range contains all elements that have changed.
    • The range may contain elements that have not changed.
    • The range may be empty (fromIndex equals toIndex) if none of the existing list variable elements have changed.
    • Specified by:
      afterListVariableChanged in interface ListVariableListener<Solution_,Object,Object>
      Parameters:
      scoreDirector - score director
      entity - entity with the changed list variable
      fromIndex - low endpoint (inclusive) of the changed range
      toIndex - high endpoint (exclusive) of the changed range
    • getInverseSingleton

      public Object getInverseSingleton(Object planningValue)
      Description copied from interface: SingletonInverseVariableSupply
      If entity1.varA = x then the inverse of x is entity1.
      Specified by:
      getInverseSingleton in interface SingletonInverseVariableSupply
      Parameters:
      planningValue - never null
      Returns:
      sometimes null, an entity for which the planning variable is the planningValue.