Interface SupplyManager
-
- All Known Implementing Classes:
VariableListenerSupport
public interface SupplyManager
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <Supply_ extends Supply>
booleancancel(Demand<Supply_> demand)Cancel an activedemand(Demand).<Supply_ extends Supply>
Supply_demand(Demand<Supply_> demand)<Supply_ extends Supply>
longgetActiveCount(Demand<Supply_> demand)
-
-
-
Method Detail
-
demand
<Supply_ extends Supply> Supply_ demand(Demand<Supply_> 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
<Supply_ extends Supply> boolean cancel(Demand<Supply_> demand)
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
-
-