Class AbstractIvmlVariable.DecVar
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.vilTypes.configuration.AbstractIvmlVariable.DecVar
-
- All Implemented Interfaces:
IConfigurationElement,IConfigurationVisitable,IDecisionVariable,IValueParent
- Enclosing class:
- AbstractIvmlVariable
private static class AbstractIvmlVariable.DecVar extends java.lang.Object implements IDecisionVariable
Implements a dynamic mapping of nested (container) values to temporary decision variables. Nested container values do not have attributes.- Author:
- Holger Eichelberger
-
-
Field Summary
Fields Modifier and Type Field Description private DecisionVariableDeclarationdeclprivate IDecisionVariable[]nestedprivate IDecisionVariableparentprivate Valuevalue
-
Constructor Summary
Constructors Modifier Constructor Description privateDecVar(IDecisionVariable parent, Value value, DecisionVariableDeclaration decl)Creates a temporary decision variable.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(IConfigurationVisitor visitor)Accepts and calls the given visitor.booleanenableWasAssignedForIsDefined()Shall we take the localIDecisionVariable.wasAssigned()overIConfigurationElement.getState()in the implementation of IVML "isDefined".voidfreeze(java.lang.String nestedElement)Causes to freeze a nested value.voidfreeze(IFreezeSelector selector)Causes to freeze the current value.IDecisionVariablegetAttribute(int index)Returns a specific attribute.intgetAttributesCount()Returns the number of attributes.ConfigurationgetConfiguration()Returns the topLevel parent.AbstractVariablegetDeclaration()Returns the declaration of the variable.intgetNestedDepth()Returns how many parentIDecisionVariables exist for this variable.IDecisionVariablegetNestedElement(int index)Returns the element specified byindex.IDecisionVariablegetNestedElement(java.lang.String name)Returns an element specified by its name.intgetNestedElementsCount()Returns the number of nested elements.IConfigurationElementgetParent()Returns the element this element is part of.java.lang.StringgetQualifiedName()Returns the qualified name of the declaration instance.IResolutionPathElementgetResolutionPath()Returns a resolution path for this variable.IAssignmentStategetState()Returns the assignment state of this variable.ValuegetValue()Returns the current value of thisIDecisionVariable.booleanhasNullValue()Checks whether the variable has aNullValue.booleanhasValue()Checks whether the variable has a configuredValue.private voidinitializeNested()Initializes nested variables.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.booleanisVisible()Returns whether this variable is visible by the user.voidnotifyCreated()Notifies this variable that it was created.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 throughCommandAssignmentState#compareTo(CommandAssignmentState).booleanremoveDerivedValues()Removes 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.voidunfreeze(IAssignmentState state)Causes to unfreeze the current value.booleanwasAssigned()Returns whether a value was assigned (correlated, but independent ofIConfigurationElement.getState()).booleanwasCreated()Returns whether the variable value was explicitly created.
-
-
-
Field Detail
-
parent
private IDecisionVariable parent
-
value
private Value value
-
decl
private DecisionVariableDeclaration decl
-
nested
private IDecisionVariable[] nested
-
-
Constructor Detail
-
DecVar
private DecVar(IDecisionVariable parent, Value value, DecisionVariableDeclaration decl)
Creates a temporary decision variable.- Parameters:
parent- the parent variablevalue- the actual valuedecl- the related decision variable declaration (may be null, then a temporary one is created)
-
-
Method Detail
-
initializeNested
private void initializeNested()
Initializes nested variables.
-
getParent
public IConfigurationElement 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
public 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
public IAssignmentState getState()
Description copied from interface:IConfigurationElementReturns the assignment state of this variable.- Specified by:
getStatein interfaceIConfigurationElement- Returns:
- the assignment state
-
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
-
freeze
public void freeze(IFreezeSelector selector)
Description copied from interface:IConfigurationElementCauses to freeze the current value.- Specified by:
freezein interfaceIConfigurationElement- Parameters:
selector- determines which parts shall be frozen
-
unfreeze
public void unfreeze(IAssignmentState state)
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
public void freeze(java.lang.String nestedElement)
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
public AbstractVariable getDeclaration()
Description copied from interface:IConfigurationElementReturns the declaration of the variable.- Specified by:
getDeclarationin interfaceIConfigurationElement- Returns:
- the declaration of the decision variable
-
accept
public void accept(IConfigurationVisitor visitor)
Description copied from interface:IConfigurationVisitableAccepts and calls the given visitor.- Specified by:
acceptin interfaceIConfigurationVisitable- Parameters:
visitor- the visitor
-
getValue
public Value getValue()
Description copied from interface:IDecisionVariableReturns the current value of thisIDecisionVariable.- Specified by:
getValuein interfaceIDecisionVariable- Returns:
- the value (may be null)
-
setValue
public void setValue(Value value, IAssignmentState state) throws ConfigurationException
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, 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
-
setHistoryValue
public void setHistoryValue(Value value, IAssignmentState state) throws ConfigurationException
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
public IDecisionVariable getNestedElement(int index)
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
-
getNestedElement
public IDecisionVariable getNestedElement(java.lang.String name)
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
public IDecisionVariable getAttribute(int index)
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:
- false if the variable is hidden by an interface, true otherwise
-
hasValue
public boolean hasValue()
Description copied from interface:IDecisionVariableChecks whether the variable has a configuredValue.- Specified by:
hasValuein interfaceIDecisionVariable- Returns:
- true if the variable has a value, false otherwise.
-
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:
- true if the variable has a
NullValue, false otherwise.
-
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:
- true if there was a change, false if the variable keeps unchanged.
-
getQualifiedName
public java.lang.String 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
public IResolutionPathElement 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:
- false if the variable is not local and part of an usual configuration,
trueif the variable is local
-
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
public boolean notifyWasAssigned(Value value)
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 throughCommandAssignmentState#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().
-
-