Interface SupplyManager
- All Known Implementing Classes:
VariableListenerSupport
public interface SupplyManager
-
Method Summary
Modifier and TypeMethodDescription<Supply_ extends Supply>
booleanCancel an activedemand(Demand).<Supply_ extends Supply>
Supply_<Supply_ extends Supply>
longgetActiveCount(Demand<Supply_> demand) Returns aConsumerthat notifies internal components (such asNeighborhoodsBasedMoveRepository) when theSupplychanges.
-
Method Details
-
getStateChangeNotifier
Returns aConsumerthat notifies internal components (such asNeighborhoodsBasedMoveRepository) when theSupplychanges.This is required to be used for externalized supplies (such as
ExternalizedSingletonInverseVariableSupply), since their state can change without modifying any variables on an entity.- Returns:
- never null
-
demand
Returns 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 bycancel(Demand).- Type Parameters:
Supply_- Subclass ofSupply- Parameters:
demand- never null- Returns:
- never null
-
cancel
Cancel an activedemand(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.- Type Parameters:
Supply_-- Parameters:
demand- never null- Returns:
- true if the counter was decremented, false if there is no such supply
-
getActiveCount
-