Class VariableAccessor


class VariableAccessor extends AbstractDecisionVariableEvaluationAccessor
Implements an accessor for decision variables. This class supports IEvaluationInterceptor.
Author:
Holger Eichelberger
  • Field Details

    • POOL

      public static final net.ssehub.easy.basics.pool.Pool<VariableAccessor> POOL
  • Constructor Details

    • VariableAccessor

      private VariableAccessor()
      Creates an instance. Private due to pooling.
  • Method Details

    • bind

      public VariableAccessor bind(AbstractVariable variable, EvaluationContext context)
      Binds the accessor to the given variable and context.
      Parameters:
      variable - the underlying variable
      context - the evaluation context
      Returns:
      this (builder pattern)
    • bind

      public VariableAccessor bind(IDecisionVariable variable, EvaluationContext context)
      Binds the accessor to the given (non-local) variable and context.
      Overrides:
      bind in class AbstractDecisionVariableEvaluationAccessor
      Parameters:
      variable - the underlying variable
      context - the evaluation context
      Returns:
      this (builder pattern)
    • bind

      public VariableAccessor bind(IDecisionVariable variable, EvaluationContext context, boolean isLocal)
      Binds the accessor to the given (local or non-local) variable and context.
      Parameters:
      variable - the underlying variable
      context - the evaluation context
      isLocal - whether the variable is local and does not need a target state check
      Returns:
      this (builder pattern)
    • getValue

      public Value getValue()
      Description copied from class: EvaluationAccessor
      Returns the value of the accessed element.
      Specified by:
      getValue in class EvaluationAccessor
      Returns:
      the value (may be null if undefined)
    • setValue

      public boolean setValue(Value value, boolean asAssignment)
      Description copied from class: EvaluationAccessor
      Defines a new value for the accessed element. In case of failures, add appropriate messages to the context.
      Specified by:
      setValue in class EvaluationAccessor
      Parameters:
      value - the new value
      asAssignment - does this happen through an IVML assignment operation
      Returns:
      true if successful, false else
    • setValue

      private boolean setValue(EvaluationContext context, Value value, boolean asAssignment)
      Changes the value within the given evaluation context.
      Parameters:
      context - the evaluation context
      value - the new value
      asAssignment - called within an assignment or equality expression
      Returns:
      true for success, false else
    • isAssignable

      public boolean isAssignable()
      Description copied from class: EvaluationAccessor
      Returns whether values can be assigned to this evaluator.
      Specified by:
      isAssignable in class EvaluationAccessor
      Returns:
      true if values can be assigned, false else
    • getValue

      public EvaluationAccessor getValue(EvaluationAccessor accessor)
      Description copied from class: EvaluationAccessor
      Returns a nested value based on the given accessor.
      Overrides:
      getValue in class EvaluationAccessor
      Parameters:
      accessor - the accessor to determine the nested value
      Returns:
      the nested value
    • getIndex

      private Integer getIndex(ContainerValue value, EvaluationAccessor accessor)
      Returns the (valid) index from accessor for value.
      Parameters:
      value - the container to be accessed
      accessor - the accessor expression
      Returns:
      the index value (invalid if null)
    • setValue

      public void setValue(EvaluationAccessor accessor, Value value)
      Changes a nested value based on the given accessor.
      Overrides:
      setValue in class EvaluationAccessor
      Parameters:
      accessor - the accessor to determine the nested value
      value - the new nested value
    • release

      public void release()
      Description copied from class: EvaluationAccessor
      Releases this instance.
      Specified by:
      release in class EvaluationAccessor