Package org.optaplanner.core.impl.domain.variable.anchor

## Class AnchorVariableListener<Solution_>

- java.lang.Object
- - org.optaplanner.core.impl.domain.variable.anchor.AnchorVariableListener<Solution_>

- Type Parameters:
    `Solution_` - the solution type, the class with the `PlanningSolution` annotation
  All Implemented Interfaces:
    `Closeable`, `AutoCloseable`, `VariableListener<Object>`, `AnchorVariableSupply`, `VariableListener<Object>`, `Supply`

      public class AnchorVariableListener<Solution_>
      extends Object
      implements VariableListener<Object>, AnchorVariableSupply

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected AnchorShadowVariableDescriptor<Solution_>` | `anchorShadowVariableDescriptor` |
    `protected SingletonInverseVariableSupply` | `nextVariableSupply` |
    `protected VariableDescriptor<Solution_>` | `previousVariableDescriptor` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `AnchorVariableListener​(AnchorShadowVariableDescriptor<Solution_> anchorShadowVariableDescriptor, VariableDescriptor<Solution_> previousVariableDescriptor, SingletonInverseVariableSupply nextVariableSupply)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `afterEntityAdded​(ScoreDirector scoreDirector, Object entity)` |
    `void` | `afterEntityRemoved​(ScoreDirector scoreDirector, Object entity)` |
    `void` | `afterVariableChanged​(ScoreDirector scoreDirector, Object entity)` |
    `void` | `beforeEntityAdded​(ScoreDirector scoreDirector, Object entity)` |
    `void` | `beforeEntityRemoved​(ScoreDirector scoreDirector, Object entity)` |
    `void` | `beforeVariableChanged​(ScoreDirector scoreDirector, Object entity)` |
    `Object` | `getAnchor​(Object entity)` |
    `protected void` | `insert​(ScoreDirector scoreDirector, Object entity)` |

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

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

    - ### Methods inherited from interface org.optaplanner.core.api.domain.variable.VariableListener

      `close, resetWorkingSolution`

    - ### Methods inherited from interface org.optaplanner.core.impl.domain.variable.listener.VariableListener

      `requiresUniqueEntityEvents`

- - ### Field Detail

    - #### anchorShadowVariableDescriptor

          protected final AnchorShadowVariableDescriptor<Solution_> anchorShadowVariableDescriptor

    - #### previousVariableDescriptor

          protected final VariableDescriptor<Solution_> previousVariableDescriptor

    - #### nextVariableSupply

          protected final SingletonInverseVariableSupply nextVariableSupply

  - ### Constructor Detail

    - #### AnchorVariableListener

          public AnchorVariableListener​(AnchorShadowVariableDescriptor<Solution_> anchorShadowVariableDescriptor,
                                        VariableDescriptor<Solution_> previousVariableDescriptor,
                                        SingletonInverseVariableSupply nextVariableSupply)

  - ### Method Detail

    - #### beforeEntityAdded

          public void beforeEntityAdded​(ScoreDirector scoreDirector,
                                        Object entity)

      Specified by:
        `beforeEntityAdded` in interface `VariableListener<Solution_>`
      Specified by:
        `beforeEntityAdded` in interface `VariableListener<Solution_>`
      Parameters:
        `scoreDirector` - never null
        `entity` - never null

    - #### afterEntityAdded

          public void afterEntityAdded​(ScoreDirector scoreDirector,
                                       Object entity)

      Specified by:
        `afterEntityAdded` in interface `VariableListener<Solution_>`
      Specified by:
        `afterEntityAdded` in interface `VariableListener<Solution_>`
      Parameters:
        `scoreDirector` - never null
        `entity` - never null

    - #### beforeVariableChanged

          public void beforeVariableChanged​(ScoreDirector scoreDirector,
                                            Object entity)

      Specified by:
        `beforeVariableChanged` in interface `VariableListener<Solution_>`
      Specified by:
        `beforeVariableChanged` in interface `VariableListener<Solution_>`
      Parameters:
        `scoreDirector` - never null
        `entity` - never null

    - #### afterVariableChanged

          public void afterVariableChanged​(ScoreDirector scoreDirector,
                                           Object entity)

      Specified by:
        `afterVariableChanged` in interface `VariableListener<Solution_>`
      Specified by:
        `afterVariableChanged` in interface `VariableListener<Solution_>`
      Parameters:
        `scoreDirector` - never null
        `entity` - never null

    - #### beforeEntityRemoved

          public void beforeEntityRemoved​(ScoreDirector scoreDirector,
                                          Object entity)

      Specified by:
        `beforeEntityRemoved` in interface `VariableListener<Solution_>`
      Specified by:
        `beforeEntityRemoved` in interface `VariableListener<Solution_>`
      Parameters:
        `scoreDirector` - never null
        `entity` - never null

    - #### afterEntityRemoved

          public void afterEntityRemoved​(ScoreDirector scoreDirector,
                                         Object entity)

      Specified by:
        `afterEntityRemoved` in interface `VariableListener<Solution_>`
      Specified by:
        `afterEntityRemoved` in interface `VariableListener<Solution_>`
      Parameters:
        `scoreDirector` - never null
        `entity` - never null

    - #### insert

          protected void insert​(ScoreDirector scoreDirector,
                                Object entity)

    - #### getAnchor

          public Object getAnchor​(Object entity)

      Specified by:
        `getAnchor` in interface `AnchorVariableSupply`
      Parameters:
        `entity` - never null
      Returns:
        sometimes null, the anchor for the entity