Annotation Type CustomShadowVariable


@Deprecated(forRemoval=true) @Target({METHOD,FIELD}) @Retention(RUNTIME) public @interface CustomShadowVariable
Deprecated, for removal: This API element is subject to removal in a future version.
Deprecated in favor of ShadowVariable (normal shadow variable with variableListenerClass()) and PiggybackShadowVariable (if variableListenerRef() is used).
This annotation is deprecated. Below are the instructions on how to replace your @CustomShadowVariable(...) with either @ShadowVariable or @PiggybackShadowVariable.

If your @CustomShadowVariable uses the variableListenerClass attribute, then replace the annotation with one @ShadowVariable annotation for each source @PlanningVariableReference.

For example,

 @CustomShadowVariable(
     variableListenerClass = PredecessorsDoneDateUpdatingVariableListener.class,
     sources = {
         @PlanningVariableReference(variableName = "executionMode"),
         @PlanningVariableReference(variableName = "delay") })
 
becomes:
 @ShadowVariable(
     variableListenerClass = PredecessorsDoneDateUpdatingVariableListener.class,
     sourceVariableName = "executionMode")
 @ShadowVariable(
     variableListenerClass = PredecessorsDoneDateUpdatingVariableListener.class,
     sourceVariableName = "delay")
 

If your @CustomShadowVariable uses the variableListenerRef attribute, then replace it with the @PiggybackShadowVariable annotation.

For example,

 @CustomShadowVariable(
     variableListenerRef = @PlanningVariableReference(variableName = "date"))
 
becomes:
 @PiggybackShadowVariable(shadowVariableName = "date")
 
Specifies that a bean property (or a field) is a custom shadow variable of 1 or more PlanningVariables.

It is specified on a getter of a java bean property (or a field) of a PlanningEntity class.

  • Element Details

    • variableListenerClass

      Class<? extends VariableListener> variableListenerClass
      Deprecated, for removal: This API element is subject to removal in a future version.
      A VariableListener gets notified after a source planning variable has changed. That listener changes the shadow variable (often recursively on multiple planning entities) accordingly. Those shadow variables should make the score calculation more natural to write.

      For example: VRP with time windows uses a VariableListener to update the arrival times of all the trailing entities when an entity is changed.

      Returns:
      never null (unless variableListenerRef() is not null)
      Default:
      org.optaplanner.core.api.domain.variable.CustomShadowVariable.NullVariableListener.class
    • sources

      Deprecated, for removal: This API element is subject to removal in a future version.
      The source variables (leaders) that trigger a change to this shadow variable (follower).
      Returns:
      never null (unless variableListenerRef() is not null), at least 1
      Default:
      {}
    • variableListenerRef

      PlanningVariableReference variableListenerRef
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use this when this shadow variable is updated by the VariableListener of another CustomShadowVariable.
      Returns:
      null if (and only if) any of the other fields is non null.
      Default:
      @org.optaplanner.core.api.domain.variable.PlanningVariableReference(variableName="")