Class VariableListenerSupport<Solution_>

  • Type Parameters:
    Solution_ - the solution type, the class with the PlanningSolution annotation
    All Implemented Interfaces:
    SupplyManager

    public final class VariableListenerSupport<Solution_>
    extends Object
    implements SupplyManager
    This class is not thread-safe.
    • Method Detail

      • linkVariableListeners

        public void linkVariableListeners()
      • demand

        public <Supply_ extends Supply> Supply_ demand​(Demand<Supply_> demand)
        Description copied from interface: SupplyManager
        Returns the Supply for a Demand, preferably an existing one. If the Supply doesn't exist yet (as part of the domain model or externalized), it creates and attaches it. If two Demand instances are equal, they will result in the same Supply instance. Each supply instance keeps a counter of how many times it was requested, which can be decremented by SupplyManager.cancel(Demand).
        Specified by:
        demand in interface SupplyManager
        Type Parameters:
        Supply_ - Subclass of Supply
        Parameters:
        demand - never null
        Returns:
        never null
      • cancel

        public <Supply_ extends Supply> boolean cancel​(Demand<Supply_> demand)
        Description copied from interface: SupplyManager
        Cancel an active SupplyManager.demand(Demand). Once the number of active demands reaches zero, the Supply 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.

        Specified by:
        cancel in interface SupplyManager
        Parameters:
        demand - never null
        Returns:
        true if the counter was decremented, false if there is no such supply
      • resetWorkingSolution

        public void resetWorkingSolution()
      • close

        public void close()
      • 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()