Class LocalDecisionVariable
java.lang.Object
net.ssehub.easy.varModel.cstEvaluation.LocalDecisionVariable
- All Implemented Interfaces:
IConfigurationElement,IConfigurationVisitable,IDecisionVariable,IValueParent
A local decision variable representing a parameter or a local variable. A local decision variable
must also return local decision variables (in order to remain "local").
- Author:
- Holger Eichelberger
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate IConfigurationprivate DecisionVariableDeclaration(package private) static final Stringprivate IValueChangeListenerprivate IDecisionVariableprivate IAssignmentStateprivate Value -
Constructor Summary
ConstructorsConstructorDescriptionLocalDecisionVariable(DecisionVariableDeclaration decl, IConfiguration conf, IDecisionVariable parent) Creates a local decision variable. -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(IConfigurationVisitor visitor) Accepts and calls the given visitor.booleanShall we take the localIDecisionVariable.wasAssigned()overIConfigurationElement.getState()in the implementation of IVML "isDefined".voidCauses to freeze a nested value.voidfreeze(IFreezeSelector selector) Causes to freeze the current value.getAttribute(int index) Returns a specific attribute.intReturns the number of attributes.Returns the topLevel parent.Returns the declaration of the variable.intReturns how many parentIDecisionVariables exist for this variable.getNestedElement(int index) Returns the element specified byindex.getNestedElement(String name) Returns an element specified by its name.intReturns the number of nested elements.getNestedVariable(String slotName) Returns the nested variable for the given slot name.Returns the element this element is part of.Returns the qualified name of the declaration instance.Returns a resolution path for this variable.getState()Returns the assignment state of this variable.getValue()Returns the current value of thisIDecisionVariable.private IValueParentgetValueParent(Value value) Returns the value parent ofvalue.Returns the underlying variable.booleanChecks whether the variable has aNullValue.booleanhasValue()Checks whether the variable has a configuredValue.booleanisLocal()Returns whether this variable is local, e.g., as a parameter of a user-defined function, a variable defined by a let-expression, or an iterator in a container operation.booleanisNested()Returns whether this decision variable is nested.booleanReturns whether this variable is visible by the user.voidNotifies this variable that it was created.private voidnotifyValueChanged(Value oldValue, IAssignmentState oldState, IValueChangeListener.ChangeKind kind) Notifies the change listener if defined.booleannotifyWasAssigned(Value value) Inform the variable independent of its own tracking that we believe that a value was assigned (although we did not due to equal values/performance reasons), in particular after resetting the track throughEnum.compareTo(CommandAssignmentState).private IValueParentobtainValueParent(Value value) Obtains the value parent for the stored value, the given value or the value of one of the parents.booleanRemoves all (nested) values which are in stateAssignmentState.DERIVED, i.e., all values which are propagated bay the reasoner.voidsetHistoryValue(Value value, IAssignmentState state) Changes the value (for incremental buildup) from value history.voidsetValue(Value value, IAssignmentState state) Changes the value (for incremental buildup).voidsetValue(Value value, IAssignmentState state, boolean asAssignment) Changes the value.voidsetValue(Value value, IAssignmentState state, IConfigurationElement nested) Changes the value of a nested variable.voidsetValueChangeListener(IValueChangeListener listener) Defines the value change listener to be informed.voidsetVariable(IDecisionVariable variable) Changes the underlying variable taking precedence over the stored value.voidunfreeze(IAssignmentState state) Causes to unfreeze the current value.booleanReturns whether a value was assigned (correlated, but independent ofIConfigurationElement.getState()).booleanReturns whether the variable value was explicitly created.
-
Field Details
-
ITERATOR_RESULT_VARNAME
- See Also:
-
decl
-
value
-
state
-
conf
-
parent
-
listener
-
-
Constructor Details
-
LocalDecisionVariable
public LocalDecisionVariable(DecisionVariableDeclaration decl, IConfiguration conf, IDecisionVariable parent) Creates a local decision variable.- Parameters:
decl- the defining variable declarationconf- the configurationparent- the parent decision variable for call-by-reference, may be null
-
-
Method Details
-
getParent
Description copied from interface:IConfigurationElementReturns the element this element is part of.- Specified by:
getParentin interfaceIConfigurationElement- Returns:
- the parent element (may be null in case of the top-level configuration)
-
getConfiguration
Description copied from interface:IConfigurationElementReturns the topLevel parent.- Specified by:
getConfigurationin interfaceIConfigurationElement- Returns:
- should be the configuration
-
isNested
public boolean isNested()Description copied from interface:IConfigurationElementReturns whether this decision variable is nested. Being member of aConfigurationdoes not imply.isNested== true- Specified by:
isNestedin interfaceIConfigurationElement- Returns:
trueif it is nested in another decision variable,falseelse
-
getState
Description copied from interface:IConfigurationElementReturns the assignment state of this variable.- Specified by:
getStatein interfaceIConfigurationElement- Returns:
- the assignment state
-
notifyValueChanged
private void notifyValueChanged(Value oldValue, IAssignmentState oldState, IValueChangeListener.ChangeKind kind) Notifies the change listener if defined.- Parameters:
oldValue- the old value before the change, may be nulloldState- the old state ofvariablebefore the changekind- the change kind
-
setValue
public void setValue(Value value, IAssignmentState state, boolean asAssignment) throws ConfigurationException Description copied from interface:IDecisionVariableChanges the value.- Specified by:
setValuein interfaceIDecisionVariable- Parameters:
value- the value (may be null for incremental buildup)state- the related assignment stateasAssignment- does this call happen as part of evaluating an IVML assignment operation- Throws:
ConfigurationException- in case that the types ofIConfigurationElement.getDeclaration()andvaluedo not comply
-
setValue
Description copied from interface:IDecisionVariableChanges the value (for incremental buildup).- Specified by:
setValuein interfaceIDecisionVariable- Parameters:
value- the value (may be null for incremental buildup)state- the related assignment state- Throws:
ConfigurationException- in case that the types ofIConfigurationElement.getDeclaration()andvaluedo not comply
-
setValue
public void setValue(Value value, IAssignmentState state, IConfigurationElement nested) throws ConfigurationException Description copied from interface:IConfigurationElementChanges the value of a nested variable.- Specified by:
setValuein interfaceIConfigurationElement- Parameters:
value- the new valuestate- the new assignment statenested- the nested variable to be considered in the parent- Throws:
ConfigurationException- in case of type incompatibilities
-
obtainValueParent
Obtains the value parent for the stored value, the given value or the value of one of the parents.- Parameters:
value- the value to consider (may be null)- Returns:
- the value parent, may be null for none
-
getValueParent
Returns the value parent ofvalue.- Parameters:
value- the value to return the parent for (may be null)- Returns:
- the value parent (may be null)
-
freeze
Description copied from interface:IConfigurationElementCauses to freeze the current value.- Specified by:
freezein interfaceIConfigurationElement- Parameters:
selector- determines which parts shall be frozen
-
unfreeze
Description copied from interface:IConfigurationElementCauses to unfreeze the current value.- Specified by:
unfreezein interfaceIConfigurationElement- Parameters:
state- the target state for unfreezing (must not beAssignmentState.FROZEN)
-
freeze
Description copied from interface:IConfigurationElementCauses to freeze a nested value.- Specified by:
freezein interfaceIConfigurationElement- Parameters:
nestedElement- The name of the nested Element, which should be frozen.
-
getDeclaration
Description copied from interface:IConfigurationElementReturns the declaration of the variable.- Specified by:
getDeclarationin interfaceIConfigurationElement- Returns:
- the declaration of the decision variable
-
accept
Description copied from interface:IConfigurationVisitableAccepts and calls the given visitor.- Specified by:
acceptin interfaceIConfigurationVisitable- Parameters:
visitor- the visitor
-
getValue
Description copied from interface:IDecisionVariableReturns the current value of thisIDecisionVariable.- Specified by:
getValuein interfaceIDecisionVariable- Returns:
- the value (may be null)
-
setHistoryValue
Description copied from interface:IDecisionVariableChanges the value (for incremental buildup) from value history.- Specified by:
setHistoryValuein interfaceIDecisionVariable- Parameters:
value- the value (may be null for incremental buildup)state- the related assignment state- Throws:
ConfigurationException- in case that the types ofIConfigurationElement.getDeclaration()andvaluedo not comply
-
getNestedElementsCount
public int getNestedElementsCount()Description copied from interface:IDecisionVariableReturns the number of nested elements. The return value should be 0 unless thisIDecisionVariableis a- Specified by:
getNestedElementsCountin interfaceIDecisionVariable- Returns:
- An integer value greater or equal to 0.
-
getNestedElement
Description copied from interface:IDecisionVariableReturns the element specified byindex. [also req SAP]- Specified by:
getNestedElementin interfaceIDecisionVariable- Parameters:
index- a 0-based index specifying the element to be returned- Returns:
- the element
-
getNestedVariable
Returns the nested variable for the given slot name.- Parameters:
slotName- the slot name- Returns:
- the nested variable or null if it does not exist
-
getNestedElement
Description copied from interface:IDecisionVariableReturns an element specified by its name.- Specified by:
getNestedElementin interfaceIDecisionVariable- Parameters:
name- the name of the nested element- Returns:
- the nested element (may be null)
-
getAttributesCount
public int getAttributesCount()Description copied from interface:IDecisionVariableReturns the number of attributes.- Specified by:
getAttributesCountin interfaceIDecisionVariable- Returns:
- the number of attributes
-
getAttribute
Description copied from interface:IDecisionVariableReturns a specific attribute.- Specified by:
getAttributein interfaceIDecisionVariable- Parameters:
index- the index of the attribute- Returns:
- the attribute
-
getNestedDepth
public int getNestedDepth()Description copied from interface:IDecisionVariableReturns how many parentIDecisionVariables exist for this variable.- Specified by:
getNestedDepthin interfaceIDecisionVariable- Returns:
- 0 if the Configuration is the direct parent of this
IDecisionVariable, otherwise a number greater than 0 indicating how manyIDecisionVariables between theConfigurationand this variable exist.
-
isVisible
public boolean isVisible()Description copied from interface:IDecisionVariableReturns whether this variable is visible by the user.- Specified by:
isVisiblein interfaceIDecisionVariable- Returns:
falseif the variable is hidden by an interface,trueotherwise
-
hasValue
public boolean hasValue()Description copied from interface:IDecisionVariableChecks whether the variable has a configuredValue.- Specified by:
hasValuein interfaceIDecisionVariable- Returns:
trueif the variable has a value,falseotherwise.
-
hasNullValue
public boolean hasNullValue()Description copied from interface:IDecisionVariableChecks whether the variable has aNullValue. Note: this method does not check whether the variable has a value.- Specified by:
hasNullValuein interfaceIDecisionVariable- Returns:
trueif the variable has aNullValue,falseotherwise.
-
removeDerivedValues
public boolean removeDerivedValues()Description copied from interface:IDecisionVariableRemoves all (nested) values which are in stateAssignmentState.DERIVED, i.e., all values which are propagated bay the reasoner. This will keep all user assignedAssignmentState.ASSIGNEDand frozenAssignmentState.FROZENvalues.- Specified by:
removeDerivedValuesin interfaceIDecisionVariable- Returns:
trueif there was a change,falseif the variable keeps unchanged.
-
getQualifiedName
Description copied from interface:IDecisionVariableReturns the qualified name of the declaration instance. This is build as follows:
<Project name> :: [<Parent name>::]* <Declaration name>- Specified by:
getQualifiedNamein interfaceIDecisionVariable- Returns:
- The qualified and unique name of the variable.
-
getResolutionPath
Description copied from interface:IDecisionVariableReturns a resolution path for this variable.- Specified by:
getResolutionPathin interfaceIDecisionVariable- Returns:
- the resolution path
-
isLocal
public boolean isLocal()Description copied from interface:IDecisionVariableReturns whether this variable is local, e.g., as a parameter of a user-defined function, a variable defined by a let-expression, or an iterator in a container operation.- Specified by:
isLocalin interfaceIDecisionVariable- Returns:
falseif the variable is not local and part of an usual configuration,trueif the variable is local
-
setVariable
Changes the underlying variable taking precedence over the stored value.- Parameters:
variable- the variable (may be null) to ignore
-
getVariable
Returns the underlying variable.- Returns:
- variable the variable (may be null)
-
setValueChangeListener
Defines the value change listener to be informed.- Parameters:
listener- the listener instance or null for none
-
wasCreated
public boolean wasCreated()Description copied from interface:IConfigurationElementReturns whether the variable value was explicitly created.- Specified by:
wasCreatedin interfaceIConfigurationElement- Returns:
truefor created,falseelse
-
notifyCreated
public void notifyCreated()Description copied from interface:IDecisionVariableNotifies this variable that it was created.- Specified by:
notifyCreatedin interfaceIDecisionVariable
-
notifyWasAssigned
Description copied from interface:IDecisionVariableInform the variable independent of its own tracking that we believe that a value was assigned (although we did not due to equal values/performance reasons), in particular after resetting the track throughEnum.compareTo(CommandAssignmentState).- Specified by:
notifyWasAssignedin interfaceIDecisionVariable- Parameters:
value- the new value- Returns:
truewhether this variable was defined before,falseelse
-
wasAssigned
public boolean wasAssigned()Description copied from interface:IDecisionVariableReturns whether a value was assigned (correlated, but independent ofIConfigurationElement.getState()).- Specified by:
wasAssignedin interfaceIDecisionVariable- Returns:
trueif a value was assigned,falseelse
-
enableWasAssignedForIsDefined
public boolean enableWasAssignedForIsDefined()Description copied from interface:IDecisionVariableShall we take the localIDecisionVariable.wasAssigned()overIConfigurationElement.getState()in the implementation of IVML "isDefined".- Specified by:
enableWasAssignedForIsDefinedin interfaceIDecisionVariable- Returns:
truetakeIDecisionVariable.wasAssigned(),falseforIConfigurationElement.getState().
-