Class ConstantAccessor
- java.lang.Object
-
- net.ssehub.easy.varModel.cstEvaluation.EvaluationAccessor
-
- net.ssehub.easy.varModel.cstEvaluation.ConstantAccessor
-
public class ConstantAccessor extends EvaluationAccessor
Implements an accessor for constant values. [public for testing]- Author:
- Holger Eichelberger
-
-
Field Summary
Fields Modifier and Type Field Description private booleanisConstantstatic Pool<ConstantAccessor>POOLprivate Valuevalue
-
Constructor Summary
Constructors Modifier Constructor Description privateConstantAccessor()Creates an instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConstantAccessorbind(Value value, boolean isConstant, EvaluationContext context)Binds the accessor to the given value and context.voidclear()Clears the accessor for reuse.ValuegetReferenceValue()Returns the value of a reference to the accessed element.ValuegetValue()Returns the value of the accessed element.EvaluationAccessorgetValue(EvaluationAccessor accessor)Returns a nested value based on the given accessor.IDecisionVariablegetVariable()Returns the underlying variable.booleanisAssignable()Returns whether values can be assigned to this evaluator.booleanisConstant()Returns whether this accessor represents a constant in the sense of the evaluation process, i.e., a value that is already evaluated to its very end and not linked to any decision variable.voidrelease()Releases this instance.booleansetValue(Value value, boolean asAssignment)Defines a new value for the accessed element.java.lang.StringtoString()-
Methods inherited from class net.ssehub.easy.varModel.cstEvaluation.EvaluationAccessor
addBoundContainerElement, addBoundContainerElement, bind, bindContainer, bindContainer, clearContainerElements, dereferenceIfNeeded, getBoundContainerElement, getBoundContainerElementCount, getContext, getDereferencedValue, isAssigned, release, setValue, validateContext
-
-
-
-
Field Detail
-
POOL
public static final Pool<ConstantAccessor> POOL
-
value
private Value value
-
isConstant
private boolean isConstant
-
-
Method Detail
-
bind
public ConstantAccessor bind(Value value, boolean isConstant, EvaluationContext context)
Binds the accessor to the given value and context.- Parameters:
value- the actual valueisConstant- whethervalueis still (potentially) linked by reference to a decision variable (false), else whether it is actually a truely constantcontext- the evaluation context- Returns:
- this (builder pattern)
-
clear
public void clear()
Description copied from class:EvaluationAccessorClears the accessor for reuse.- Overrides:
clearin classEvaluationAccessor
-
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
-
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
-
release
public void release()
Description copied from class:EvaluationAccessorReleases this instance.- Specified by:
releasein classEvaluationAccessor
-
getVariable
public IDecisionVariable getVariable()
Description copied from class:EvaluationAccessorReturns the underlying variable.- Specified by:
getVariablein classEvaluationAccessor- Returns:
- the underlying variable (may be null)
-
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
-
getReferenceValue
public Value getReferenceValue()
Description copied from class:EvaluationAccessorReturns the value of a reference to the accessed element.- Specified by:
getReferenceValuein classEvaluationAccessor- Returns:
- the value (may be null if undefined)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
isConstant
public boolean isConstant()
Description copied from class:EvaluationAccessorReturns whether this accessor represents a constant in the sense of the evaluation process, i.e., a value that is already evaluated to its very end and not linked to any decision variable.- Overrides:
isConstantin classEvaluationAccessor- Returns:
truefor constant,falseelse
-
-