Class DecisionVariable
java.lang.Object
net.ssehub.easy.varModel.confModel.DecisionVariable
- All Implemented Interfaces:
IConfigurationElement,IConfigurationVisitable,IDecisionVariable,IValueParent
- Direct Known Subclasses:
BasisVariable,StructuredVariable
Implements a decision variable representing a specific decision.
Initializes and stores attributes on decision variables.
- Author:
- Holger Eichelberger, El-Sharkawy
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classInitializes annotation variables of the containing decision variable. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate IDecisionVariable[]private VariableConfigProviderprivate AbstractVariableprivate booleanprivate booleanprivate IConfigurationElementprivate boolean -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDecisionVariable(IConfigurationElement parent, AbstractVariable varDeclaration, boolean isVisible, boolean isAttribute) Creates a new decision variable representing a specific decision. -
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".voidfreeze(IFreezeSelector selector) Causes to freeze the current value.getAttribute(int index) Returns a specific attribute.intReturns the number of attributes.(package private) VariableConfigProviderGetter for theVariableConfigProvider.final ConfigurationReturns the topLevel parent.Returns the declaration of the variable.Returns one of the actual types required to instantiate this variable.final intReturns how many parentIDecisionVariables exist for this variable.getNestedElement(String name) Returns an element specified by its name.final IConfigurationElementReturns the element this element is part of.protected IResolutionPathElementReturns the resolution path for a nested element.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.booleanChecks whether the variable has aNullValue.booleanhasValue()Checks whether the variable has a configuredValue.protected booleanReturns whether this decision variable represents an attribute.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.final booleanisNested()Returns whether this decision variable is nested.booleanReturns whether this variable is visible by the user.voidNotifies 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 throughEnum.compareTo(CommandAssignmentState).(package private) booleanReturns whether this variable can have its ownIAssignmentState.voidsetHistoryValue(Value value, IAssignmentState state) Changes the value (for incremental buildup) from value history.(package private) voidsetIndex(int newIndex) Changes the index of the nestedDecisionVariable.(package private) voidsetState(IAssignmentState state) For setting states of nested variables.voidsetValue(Value value, IAssignmentState state) Changes the value (for incremental buildup).voidsetValue(Value value, IAssignmentState state, boolean asAssignment) Changes the value.toString()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.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface net.ssehub.easy.varModel.confModel.IConfigurationElement
freeze, setValueMethods inherited from interface net.ssehub.easy.varModel.confModel.IDecisionVariable
getNestedElement, getNestedElementsCount, removeDerivedValues
-
Field Details
-
parent
-
configProvider
-
declaration
-
attributes
-
isVisible
private boolean isVisible -
isAttribute
private boolean isAttribute -
wasAssigned
private boolean wasAssigned
-
-
Constructor Details
-
DecisionVariable
protected DecisionVariable(IConfigurationElement parent, AbstractVariable varDeclaration, boolean isVisible, boolean isAttribute) Creates a new decision variable representing a specific decision. The assignment state will beAssignmentState.UNDEFINED.- Parameters:
parent- the parent this variable is part of, typically theConfigurationinstance, but in case of compounds/container also the holdingIDecisionVariablevarDeclaration- the variable declaration instantiated by this decisionisVisible- Specifies whether this variables is exported by an interface or not:true: The variable is exported by an interface or there is no interface.false: There is an interface which does not export this variable.
isAttribute- whether this variable represents (a part of) an attribute or a variable
-
-
Method Details
-
getAttributesCount
public int getAttributesCount()Returns the number of attributes.- Specified by:
getAttributesCountin interfaceIDecisionVariable- Returns:
- the number of attributes
-
getAttribute
Returns a specific attribute.- Specified by:
getAttributein interfaceIDecisionVariable- Parameters:
index- the index of the attribute- Returns:
- the attribute
- Throws:
IndexOutOfBoundsException- ifindex<0 || index>=getAttributesCount()
-
isNested
public final 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
-
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
-
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)
-
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, 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
-
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)
-
getState
Description copied from interface:IConfigurationElementReturns the assignment state of this variable.- Specified by:
getStatein interfaceIConfigurationElement- Returns:
- the assignment state
-
getDeclaration
Description copied from interface:IConfigurationElementReturns the declaration of the variable.- Specified by:
getDeclarationin interfaceIConfigurationElement- Returns:
- the declaration of the decision variable
-
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)
-
toString
-
getNestedDepth
public final 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.
-
setIndex
void setIndex(int newIndex) Changes the index of the nestedDecisionVariable. This method is only supported if this variable is nested inside aContainerVariable. This method must be called after a nested element was removed out of the container, to ensure that this variable will retrieve the correct sub value of the relatedContainerVariable. this method will also ensure that this nested Variable will display the correct name.- Parameters:
newIndex- The new index inside the parentIDecisionVariable. This value must be in the range (this is not checked): (0 <= newIndex < getParent().getNestedElementsCount())
-
getConfigProvider
VariableConfigProvider getConfigProvider()Getter for theVariableConfigProvider.- Returns:
- Returns the
VariableConfigProviderused in this class. ThisVariableConfigProvidershould not be null, however, it can be null during initialization it can be null.
-
ownStateAllowed
boolean ownStateAllowed()Returns whether this variable can have its ownIAssignmentState.- Returns:
falseif one of the parents is aContainerVariable, otherwise it should betrue.
-
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
-
isAttribute
protected boolean isAttribute()Returns whether this decision variable represents an attribute.- Returns:
truefor attribute,falseelse
-
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
-
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.
-
setState
For setting states of nested variables.- Parameters:
state- The state of the parent, which should the nested variable also have.
-
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
-
getPathForNestedElement
Returns the resolution path for a nested element.- Parameters:
nested- the nested element- Returns:
- the resolution path
-
getInstantiatableType
Returns one of the actual types required to instantiate this variable. This is typically the type of the underlying variable declaration, but, in case of abstract variables, may also be one of the subtypes if defined. As changing the value with a different permitted type leads to a take over of the respective dynamic type, the indeterminism shall not lead to problems.- Returns:
- the instantiatable type
-
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
-
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().
-