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<Solution_,​Object>`, `AnchorVariableSupply`, `Supply`

      public class AnchorVariableListener<Solution_>
      extends Object
      implements VariableListener<Solution_,​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<Solution_> scoreDirector, Object entity)` |
    `void` | `afterEntityRemoved​(ScoreDirector<Solution_> scoreDirector, Object entity)` |
    `void` | `afterVariableChanged​(ScoreDirector<Solution_> scoreDirector, Object entity)` |
    `void` | `beforeEntityAdded​(ScoreDirector<Solution_> scoreDirector, Object entity)` |
    `void` | `beforeEntityRemoved​(ScoreDirector<Solution_> scoreDirector, Object entity)` |
    `void` | `beforeVariableChanged​(ScoreDirector<Solution_> scoreDirector, Object entity)` |
    `Object` | `getAnchor​(Object entity)` |
    `protected void` | `insert​(InnerScoreDirector<Solution_,​?> 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, requiresUniqueEntityEvents, resetWorkingSolution`

- - ### 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<Solution_> scoreDirector,
                                        Object entity)

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

    - #### afterEntityAdded

          public void afterEntityAdded​(ScoreDirector<Solution_> scoreDirector,
                                       Object entity)

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

    - #### beforeVariableChanged

          public void beforeVariableChanged​(ScoreDirector<Solution_> scoreDirector,
                                            Object entity)

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

    - #### afterVariableChanged

          public void afterVariableChanged​(ScoreDirector<Solution_> scoreDirector,
                                           Object entity)

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

    - #### beforeEntityRemoved

          public void beforeEntityRemoved​(ScoreDirector<Solution_> scoreDirector,
                                          Object entity)

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

    - #### afterEntityRemoved

          public void afterEntityRemoved​(ScoreDirector<Solution_> scoreDirector,
                                         Object entity)

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

    - #### insert

          protected void insert​(InnerScoreDirector<Solution_,​?> 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