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`

      public class VariableListenerSupport<Solution_>
      extends Object
      implements SupplyManager

- - ### 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,​List<VariableListenerNotifiable>>` | `sourceVariableToNotifiableMap` |
    `protected Map<Demand,​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()` |
    `<S extends Supply> S` | `demand​(Demand<S> 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,​List<VariableListenerNotifiable>> sourceVariableToNotifiableMap

    - #### sourceEntityToNotifiableMap

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

    - #### supplyMap

          protected final Map<Demand,​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 <S extends Supply> S demand​(Demand<S> 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`
      Type Parameters:
        `S` - 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()