java.lang.Object
org.optaplanner.core.impl.domain.variable.listener.support.violation.ShadowVariablesAssert

public final class ShadowVariablesAssert extends Object
Serves for detecting shadow variables' corruption. When a snapshot is created, it records the state of all shadow variables of all entities. The createShadowVariablesViolationMessage(long) method takes a look at the shadow variables again, compares their state with the recorded one and describes the difference in a violation message.
  • Method Details

    • takeSnapshot

      public static <Solution_> ShadowVariablesAssert takeSnapshot(SolutionDescriptor<Solution_> solutionDescriptor, Solution_ workingSolution)
    • createShadowVariablesViolationMessage

      public String createShadowVariablesViolationMessage(long violationDisplayLimit)
      Takes a look at the shadow variables of all entities and compares them against the recorded state. Every difference is added to the violation message. The first N differences up to the violationDisplayLimit are displayed in detail; the number of violations exceeding the display limit is reported at the end. The limit applies per each shadow variable descriptor.

      This method should be called after a forceful trigger of variable listeners.

      Parameters:
      violationDisplayLimit - maximum number of violations reported per shadow variable descriptor
      Returns:
      description of the violations or null if there are none