Class VariableAccessor
- java.lang.Object
-
- net.ssehub.easy.varModel.cstEvaluation.EvaluationAccessor
-
- net.ssehub.easy.varModel.cstEvaluation.AbstractDecisionVariableEvaluationAccessor
-
- net.ssehub.easy.varModel.cstEvaluation.VariableAccessor
-
class VariableAccessor extends AbstractDecisionVariableEvaluationAccessor
Implements an accessor for decision variables. This class supportsIEvaluationInterceptor.- Author:
- Holger Eichelberger
-
-
Field Summary
Fields Modifier and Type Field Description static Pool<VariableAccessor>POOL
-
Constructor Summary
Constructors Modifier Constructor Description privateVariableAccessor()Creates an instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description VariableAccessorbind(IDecisionVariable variable, EvaluationContext context)Binds the accessor to the given (non-local) variable and context.VariableAccessorbind(IDecisionVariable variable, EvaluationContext context, boolean isLocal)Binds the accessor to the given (local or non-local) variable and context.VariableAccessorbind(AbstractVariable variable, EvaluationContext context)Binds the accessor to the given variable and context.private java.lang.IntegergetIndex(ContainerValue value, EvaluationAccessor accessor)Returns the (valid) index fromaccessorforvalue.ValuegetValue()Returns the value of the accessed element.EvaluationAccessorgetValue(EvaluationAccessor accessor)Returns a nested value based on the given accessor.booleanisAssignable()Returns 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.booleansetValue(Value value, boolean asAssignment)Defines a new value for the accessed element.-
Methods inherited from class net.ssehub.easy.varModel.cstEvaluation.AbstractDecisionVariableEvaluationAccessor
clear, getReferenceValue, getVariable, isLocal, notifyVariableChange, toString
-
Methods 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 Detail
-
POOL
public static final Pool<VariableAccessor> POOL
-
-
Method Detail
-
bind
public VariableAccessor bind(AbstractVariable variable, EvaluationContext context)
Binds the accessor to the given variable and context.- Parameters:
variable- the underlying variablecontext- 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:
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
public Value 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
public boolean setValue(Value value, boolean asAssignment)
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
private boolean setValue(EvaluationContext context, Value value, boolean asAssignment)
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
public EvaluationAccessor getValue(EvaluationAccessor accessor)
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
private java.lang.Integer getIndex(ContainerValue value, EvaluationAccessor accessor)
Returns the (valid) index fromaccessorforvalue.- Parameters:
value- the container to be accessedaccessor- 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:
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
-
-