Class VariableListenerSupport<Solution_>
- java.lang.Object
-
- ai.timefold.solver.core.impl.domain.variable.listener.support.VariableListenerSupport<Solution_>
-
- Type Parameters:
Solution_- the solution type, the class with thePlanningSolutionannotation
- All Implemented Interfaces:
SupplyManager
public final class VariableListenerSupport<Solution_> extends Object implements SupplyManager
This class is not thread-safe.
-
-
Method Summary
-
-
-
Method Detail
-
create
public static <Solution_> VariableListenerSupport<Solution_> create(InnerScoreDirector<Solution_,?> scoreDirector)
-
linkVariableListeners
public void linkVariableListeners()
-
demand
public <Supply_ extends Supply> Supply_ demand(Demand<Supply_> demand)
Description copied from interface:SupplyManagerReturns theSupplyfor aDemand, preferably an existing one. If theSupplydoesn't exist yet (as part of the domain model or externalized), it creates and attaches it. If twoDemandinstancesare equal, they will result in the sameSupplyinstance. Each supply instance keeps a counter of how many times it was requested, which can be decremented bySupplyManager.cancel(Demand).- Specified by:
demandin interfaceSupplyManager- Type Parameters:
Supply_- Subclass ofSupply- Parameters:
demand- never null- Returns:
- never null
-
cancel
public <Supply_ extends Supply> boolean cancel(Demand<Supply_> demand)
Description copied from interface:SupplyManagerCancel an activeSupplyManager.demand(Demand). Once the number of active demands reaches zero, theSupplyin question is removed.This operation is optional. Supplies with active demands will live for as long as the
SupplyManagerlives, and get garbage-collected together with it.- Specified by:
cancelin interfaceSupplyManager- Parameters:
demand- never null- Returns:
- true if the counter was decremented, false if there is no such supply
-
getActiveCount
public <Supply_ extends Supply> long getActiveCount(Demand<Supply_> demand)
- Specified by:
getActiveCountin interfaceSupplyManager- Returns:
- 0 when there is no active
Supplyfor the givenDemand, more when there is one.
-
resetWorkingSolution
public void resetWorkingSolution()
-
close
public void close()
-
beforeEntityAdded
public void beforeEntityAdded(EntityDescriptor<Solution_> entityDescriptor, Object entity)
-
beforeEntityRemoved
public void beforeEntityRemoved(EntityDescriptor<Solution_> entityDescriptor, Object entity)
-
beforeVariableChanged
public void beforeVariableChanged(VariableDescriptor<Solution_> variableDescriptor, Object entity)
-
afterElementUnassigned
public void afterElementUnassigned(ListVariableDescriptor<Solution_> variableDescriptor, Object element)
-
beforeListVariableChanged
public void beforeListVariableChanged(ListVariableDescriptor<Solution_> variableDescriptor, Object entity, int fromIndex, int toIndex)
-
afterListVariableChanged
public void afterListVariableChanged(ListVariableDescriptor<Solution_> variableDescriptor, Object entity, int fromIndex, int toIndex)
-
triggerVariableListenersInNotificationQueues
public void triggerVariableListenersInNotificationQueues()
-
createShadowVariablesViolationMessage
public String createShadowVariablesViolationMessage()
- Returns:
- null if there are no violations
-
forceTriggerAllVariableListeners
public void forceTriggerAllVariableListeners(Solution_ workingSolution)
Triggers all variable listeners even though the notification queue is empty.- Parameters:
workingSolution- working solution
-
assertNotificationQueuesAreEmpty
public void assertNotificationQueuesAreEmpty()
-
-