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 Summary
Modifier and TypeMethodDescriptionvoidafterChange(InnerScoreDirector<Solution_, ?> scoreDirector, ChangeEvent_ event) voidbeforeChange(InnerScoreDirector<Solution_, ?> scoreDirector, ChangeEvent_ event) default voidclose()Called before thisInnerVariableListeneris thrown away and not used anymore.static <Solution_,Entity_>
voidforEachEntity(InnerScoreDirector<Solution_, ?> scoreDirector, Class<? extends Entity_> entityClass, Consumer<Entity_> entityConsumer) default booleanWhen set totrue, this has a performance loss.default voidresetWorkingSolution(InnerScoreDirector<Solution_, ?> scoreDirector) Called when the entire working solution changes.
-
Method Details
-
beforeChange
-
afterChange
-
requiresUniqueEntityEvents
default boolean requiresUniqueEntityEvents()When set totrue, this has a performance loss. When set tofalse, 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
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 thisInnerVariableListeneris thrown away and not used anymore.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
forEachEntity
static <Solution_,Entity_> void forEachEntity(InnerScoreDirector<Solution_, ?> scoreDirector, Class<? extends Entity_> entityClass, Consumer<Entity_> entityConsumer)
-