Class VariableAccessor
java.lang.Object
net.ssehub.easy.varModel.cstEvaluation.EvaluationAccessor
net.ssehub.easy.varModel.cstEvaluation.AbstractDecisionVariableEvaluationAccessor
net.ssehub.easy.varModel.cstEvaluation.VariableAccessor
Implements an accessor for decision variables. This class supports
IEvaluationInterceptor.- Author:
- Holger Eichelberger
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbind(IDecisionVariable variable, EvaluationContext context) Binds the accessor to the given (non-local) variable and context.bind(IDecisionVariable variable, EvaluationContext context, boolean isLocal) Binds the accessor to the given (local or non-local) variable and context.bind(AbstractVariable variable, EvaluationContext context) Binds the accessor to the given variable and context.private IntegergetIndex(ContainerValue value, EvaluationAccessor accessor) Returns the (valid) index fromaccessorforvalue.getValue()Returns the value of the accessed element.getValue(EvaluationAccessor accessor) Returns a nested value based on the given accessor.booleanReturns whether values can be assigned to this evaluator.voidrelease()Releases this instance.voidsetValue(EvaluationAccessor accessor, Value value) Changes a nested value based on the given accessor.private booleansetValue(EvaluationContext context, Value value, boolean asAssignment) Changes the value within the given evaluation context.booleanDefines a new value for the accessed element.Methods inherited from class net.ssehub.easy.varModel.cstEvaluation.AbstractDecisionVariableEvaluationAccessor
clear, getReferenceValue, getVariable, isLocal, notifyVariableChange, toStringMethods inherited from class net.ssehub.easy.varModel.cstEvaluation.EvaluationAccessor
addBoundContainerElement, addBoundContainerElement, bind, bindContainer, bindContainer, clearContainerElements, dereferenceIfNeeded, getBoundContainerElement, getBoundContainerElementCount, getContext, getDereferencedValue, isAssigned, isConstant, release, validateContext
-
Field Details
-
POOL
-
-
Constructor Details
-
VariableAccessor
private VariableAccessor()Creates an instance. Private due to pooling.
-
-
Method Details
-
bind
Binds the accessor to the given variable and context.- Parameters:
variable- the underlying variablecontext- the evaluation context- Returns:
- this (builder pattern)
-
bind
Binds the accessor to the given (non-local) variable and context.- Overrides:
bindin classAbstractDecisionVariableEvaluationAccessor- Parameters:
variable- the underlying variablecontext- 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 variablecontext- the evaluation contextisLocal- whether the variable is local and does not need atarget state check- Returns:
- this (builder pattern)
-
getValue
Description copied from class:EvaluationAccessorReturns the value of the accessed element.- Specified by:
getValuein classEvaluationAccessor- Returns:
- the value (may be null if undefined)
-
setValue
Description copied from class:EvaluationAccessorDefines a new value for the accessed element. In case of failures, add appropriate messages to the context.- Specified by:
setValuein classEvaluationAccessor- Parameters:
value- the new valueasAssignment- does this happen through an IVML assignment operation- Returns:
trueif successful,falseelse
-
setValue
Changes the value within the given evaluation context.- Parameters:
context- the evaluation contextvalue- the new valueasAssignment- called within an assignment or equality expression- Returns:
truefor success,falseelse
-
isAssignable
public boolean isAssignable()Description copied from class:EvaluationAccessorReturns whether values can be assigned to this evaluator.- Specified by:
isAssignablein classEvaluationAccessor- Returns:
trueif values can be assigned,falseelse
-
getValue
Description copied from class:EvaluationAccessorReturns a nested value based on the given accessor.- Overrides:
getValuein classEvaluationAccessor- Parameters:
accessor- the accessor to determine the nested value- Returns:
- the nested value
-
getIndex
Returns the (valid) index fromaccessorforvalue.- Parameters:
value- the container to be accessedaccessor- the accessor expression- Returns:
- the index value (invalid if null)
-
setValue
Changes a nested value based on the given accessor.- Overrides:
setValuein classEvaluationAccessor- Parameters:
accessor- the accessor to determine the nested valuevalue- the new nested value
-
release
public void release()Description copied from class:EvaluationAccessorReleases this instance.- Specified by:
releasein classEvaluationAccessor
-