Package org.optaplanner.core.impl.domain.variable.listener.support

## Class VariableListenerSupport<Solution_>

- java.lang.Object
- - org.optaplanner.core.impl.domain.variable.listener.support.VariableListenerSupport<Solution_>

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

      public class VariableListenerSupport<Solution_>
      extends Object
      implements SupplyManager<Solution_>

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected int` | `nextGlobalOrder` |
    `protected List<VariableListenerNotifiable>` | `notifiableList` |
    `protected boolean` | `notificationQueuesAreEmpty` |
    `protected InnerScoreDirector<Solution_,​?>` | `scoreDirector` |
    `protected Map<EntityDescriptor<Solution_>,​List<VariableListenerNotifiable>>` | `sourceEntityToNotifiableMap` |
    `protected Map<VariableDescriptor<Solution_>,​List<VariableListenerNotifiable>>` | `sourceVariableToNotifiableMap` |
    `protected Map<Demand<Solution_,​?>,​Supply>` | `supplyMap` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `VariableListenerSupport​(InnerScoreDirector<Solution_,​?> scoreDirector)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `afterEntityAdded​(EntityDescriptor<Solution_> entityDescriptor, Object entity)` |
    `void` | `afterEntityRemoved​(EntityDescriptor<Solution_> entityDescriptor, Object entity)` |
    `void` | `afterVariableChanged​(VariableDescriptor<Solution_> variableDescriptor, Object entity)` |
    `void` | `assertNotificationQueuesAreEmpty()` |
    `void` | `beforeEntityAdded​(EntityDescriptor<Solution_> entityDescriptor, Object entity)` |
    `void` | `beforeEntityRemoved​(EntityDescriptor<Solution_> entityDescriptor, Object entity)` |
    `void` | `beforeVariableChanged​(VariableDescriptor<Solution_> variableDescriptor, Object entity)` |
    `void` | `clearWorkingSolution()` |
    `<Supply_ extends Supply> Supply_` | `demand​(Demand<Solution_,​Supply_> demand)` | Returns the `Supply` for a `Demand`, preferably an existing one.
    `void` | `linkVariableListeners()` |
    `void` | `resetWorkingSolution()` |
    `void` | `triggerAllVariableListeners()` |
    `void` | `triggerVariableListenersInNotificationQueues()` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### scoreDirector

          protected final InnerScoreDirector<Solution_,​?> scoreDirector

    - #### notifiableList

          protected final List<VariableListenerNotifiable> notifiableList

    - #### sourceVariableToNotifiableMap

          protected final Map<VariableDescriptor<Solution_>,​List<VariableListenerNotifiable>> sourceVariableToNotifiableMap

    - #### sourceEntityToNotifiableMap

          protected final Map<EntityDescriptor<Solution_>,​List<VariableListenerNotifiable>> sourceEntityToNotifiableMap

    - #### supplyMap

          protected final Map<Demand<Solution_,​?>,​Supply> supplyMap

    - #### nextGlobalOrder

          protected int nextGlobalOrder

    - #### notificationQueuesAreEmpty

          protected boolean notificationQueuesAreEmpty

  - ### Constructor Detail

    - #### VariableListenerSupport

          public VariableListenerSupport​(InnerScoreDirector<Solution_,​?> scoreDirector)

  - ### Method Detail

    - #### linkVariableListeners

          public void linkVariableListeners()

    - #### demand

          public <Supply_ extends Supply> Supply_ demand​(Demand<Solution_,​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.
      Specified by:
        `demand` in interface `SupplyManager<Solution_>`
      Type Parameters:
        `Supply_` - Subclass of `Supply`
      Parameters:
        `demand` - never null
      Returns:
        never null

    - #### resetWorkingSolution

          public void resetWorkingSolution()

    - #### clearWorkingSolution

          public void clearWorkingSolution()

    - #### beforeEntityAdded

          public void beforeEntityAdded​(EntityDescriptor<Solution_> entityDescriptor,
                                        Object entity)

    - #### afterEntityAdded

          public void afterEntityAdded​(EntityDescriptor<Solution_> entityDescriptor,
                                       Object entity)

    - #### beforeVariableChanged

          public void beforeVariableChanged​(VariableDescriptor<Solution_> variableDescriptor,
                                            Object entity)

    - #### afterVariableChanged

          public void afterVariableChanged​(VariableDescriptor<Solution_> variableDescriptor,
                                           Object entity)

    - #### beforeEntityRemoved

          public void beforeEntityRemoved​(EntityDescriptor<Solution_> entityDescriptor,
                                          Object entity)

    - #### afterEntityRemoved

          public void afterEntityRemoved​(EntityDescriptor<Solution_> entityDescriptor,
                                         Object entity)

    - #### triggerVariableListenersInNotificationQueues

          public void triggerVariableListenersInNotificationQueues()

    - #### triggerAllVariableListeners

          public void triggerAllVariableListeners()

    - #### assertNotificationQueuesAreEmpty

          public void assertNotificationQueuesAreEmpty()