Interface InnerVariableListener<Solution_,ChangeEvent_ extends ChangeEvent>

Type Parameters:
Solution_ -
ChangeEvent_ -
All Superinterfaces:
AutoCloseable, Closeable
All Known Subinterfaces:
InnerBasicVariableListener<Solution_,Entity_>, InnerListVariableListener<Solution_,Entity_,Element_>, ListVariableStateSupply<Solution_,Entity_,Element_>, SourcedBasicVariableListener<Solution_,Entity_>, SourcedListVariableListener<Solution_,Entity_,Element_>, SourcedVariableListener<Solution_,Event_>
All Known Implementing Classes:
AnchorVariableListener, CollectionInverseVariableListener, ExternalizedAnchorVariableSupply, ExternalizedCollectionInverseVariableSupply, ExternalizedSingletonInverseVariableSupply, LegacyCustomShadowVariableBasicVariableListener, LegacyCustomShadowVariableListVariableListener, ListVariableTracker, SingletonInverseVariableListener, VariableTracker

@NullMarked public interface InnerVariableListener<Solution_,ChangeEvent_ extends ChangeEvent> extends Closeable
A listener sourced on a basic PlanningVariable.

Changes shadow variables when a source basic planning variable changes. The source variable can be either a genuine or a shadow variable.

It is recommended to keep implementations stateless. If state must be implemented, implementations may need to override the default methods (resetWorkingSolution(InnerScoreDirector), close()).

  • Method Details

    • beforeChange

      void beforeChange(InnerScoreDirector<Solution_,?> scoreDirector, ChangeEvent_ event)
    • afterChange

      void afterChange(InnerScoreDirector<Solution_,?> scoreDirector, ChangeEvent_ event)
    • requiresUniqueEntityEvents

      default boolean requiresUniqueEntityEvents()
      When set to true, this has a performance loss. When set to false, it's easier to make the listener implementation correct and fast.
      Returns:
      true to guarantee that each of the before/after methods is only called once per entity instance per operation type (add, change or remove).
    • resetWorkingSolution

      default void resetWorkingSolution(InnerScoreDirector<Solution_,?> scoreDirector)
      Called when the entire working solution changes. In this event, the other before..()/after...() methods will not be called. At this point, implementations should clear state, if any.
    • close

      default void close()
      Called before this InnerVariableListener is thrown away and not used anymore.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • forEachEntity

      static <Solution_, Entity_> void forEachEntity(InnerScoreDirector<Solution_,?> scoreDirector, Class<? extends Entity_> entityClass, Consumer<Entity_> entityConsumer)