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 theSupply
for aDemand
, preferably an existing one. If theSupply
doesn't exist yet (as part of the domain model or externalized), it creates and attaches it. If twoDemand
instancesare equal
, they will result in the sameSupply
instance. 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, theSupply
in question is removed.This operation is optional. Supplies with active demands will live for as long as the
SupplyManager
lives, 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
-