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

## Interface VariableListener<Entity_>

- All Superinterfaces:
    AutoCloseable, Closeable, Supply, VariableListener<Entity_>
  All Known Subinterfaces:
    SourcedVariableListener<Entity_>, StatefulVariableListener<Entity_>
  All Known Implementing Classes:
    ExternalizedAnchorVariableSupply, ExternalizedCollectionInverseVariableSupply, ExternalizedSingletonInverseVariableSupply

  Deprecated.
  in favor of `VariableListener`

      @Deprecated
      public interface VariableListener<Entity_>
      extends VariableListener<Entity_>, Supply

  Changes shadow variables when a genuine planning variable changes.

  Important: it must only change the shadow variable(s) for which it's configured! It should never change a genuine variable or a problem fact. It can change its shadow variable(s) on multiple entity instances (for example: an arrivalTime change affects all trailing entities too).

  Each `ScoreDirector` has a different `VariableListener` instance, so it can be stateful. If it is stateful, it must implement `StatefulVariableListener`.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `afterEntityAdded(ScoreDirector scoreDirector, Entity_ entity)` Deprecated.
    `void` | `afterEntityRemoved(ScoreDirector scoreDirector, Entity_ entity)` Deprecated.
    `void` | `afterVariableChanged(ScoreDirector scoreDirector, Entity_ entity)` Deprecated.
    `void` | `beforeEntityAdded(ScoreDirector scoreDirector, Entity_ entity)` Deprecated.
    `void` | `beforeEntityRemoved(ScoreDirector scoreDirector, Entity_ entity)` Deprecated.
    `void` | `beforeVariableChanged(ScoreDirector scoreDirector, Entity_ entity)` Deprecated.
    `default boolean` | `requiresUniqueEntityEvents()` Deprecated. When set to `true`, this has a slight performance loss in Planner.

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

      `close, resetWorkingSolution`

- - ### Method Detail

    - #### requiresUniqueEntityEvents

          default boolean requiresUniqueEntityEvents()

      Deprecated.
      When set to `true`, this has a slight performance loss in Planner. When set to `false`, it's often easier to make the listener implementation correct and fast.
      Specified by:
        `requiresUniqueEntityEvents` in interface `VariableListener<Entity_>`
      Returns:
        true to guarantee that each of the before/after methods will only be called once per entity instance per operation type (add, change or remove).

    - #### beforeEntityAdded

          void beforeEntityAdded(ScoreDirector scoreDirector,
                                 Entity_ entity)

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

    - #### afterEntityAdded

          void afterEntityAdded(ScoreDirector scoreDirector,
                                Entity_ entity)

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

    - #### beforeVariableChanged

          void beforeVariableChanged(ScoreDirector scoreDirector,
                                     Entity_ entity)

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

    - #### afterVariableChanged

          void afterVariableChanged(ScoreDirector scoreDirector,
                                    Entity_ entity)

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

    - #### beforeEntityRemoved

          void beforeEntityRemoved(ScoreDirector scoreDirector,
                                   Entity_ entity)

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

    - #### afterEntityRemoved

          void afterEntityRemoved(ScoreDirector scoreDirector,
                                  Entity_ entity)

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

Copyright © 2006–2021 JBoss by Red Hat. All rights reserved.