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)
-
Method Details
-
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
-