Class ContainerVariable
java.lang.Object
net.ssehub.easy.varModel.confModel.DecisionVariable
net.ssehub.easy.varModel.confModel.StructuredVariable
net.ssehub.easy.varModel.confModel.ContainerVariable
- All Implemented Interfaces:
IConfigurationElement,IConfigurationVisitable,IDecisionVariable,IValueParent
- Direct Known Subclasses:
SequenceVariable,SetVariable
VariableConfigProvider for nested variables of a ContainerVariable.- Author:
- El-Sharkawy
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedContainerVariable(IConfigurationElement parent, AbstractVariable varDeclaration, boolean isVisible, boolean isAttribute) Sole constructor for this class. -
Method Summary
Modifier and TypeMethodDescriptionAdds a new nested element to this variable.(package private) voidAdds a nestedIDecisionVariableto thisContainerVariable.addNestedElement(IDatatype type) Adds a new nested element to this variable.(package private) booleanReturns whether this variable support individual states for nested items.(package private) voidclear()Clears the list.voidCauses to freeze a nested value.voidfreeze(IFreezeSelector selector) Causes to freeze the current value.Returns the contained type of this container.protected StringgetElementName(int index) Returns the symbolic name for an element in this container, such as the index for sequences.getNestedElement(int index) Returns the element specified byindex.intReturns the number of nested elements.getState()Returns the assignment state of this variable.intindexOf(IDecisionVariable var) Returns the 0-based index ofvarin this container.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).booleanRemoves all (nested) values which are in stateAssignmentState.DERIVED, i.e., all values which are propagated bay the reasoner.booleanRemoves a (configured) element (IDecisionVariable) of thisContainerVariable.voidsetValue(Value value, IAssignmentState state) Changes the value (for incremental buildup).voidsetValue(Value value, IAssignmentState state, IConfigurationElement nested) Changes the value of a nested variable.Methods inherited from class net.ssehub.easy.varModel.confModel.DecisionVariable
accept, enableWasAssignedForIsDefined, getAttribute, getAttributesCount, getConfigProvider, getConfiguration, getDeclaration, getInstantiatableType, getNestedDepth, getNestedElement, getParent, getPathForNestedElement, getQualifiedName, getResolutionPath, getValue, hasNullValue, hasValue, isAttribute, isLocal, isNested, isVisible, notifyCreated, ownStateAllowed, setHistoryValue, setIndex, setState, setValue, toString, unfreeze, wasAssigned, wasCreated
-
Field Details
-
nestedElements
-
-
Constructor Details
-
ContainerVariable
protected ContainerVariable(IConfigurationElement parent, AbstractVariable varDeclaration, boolean isVisible, boolean isAttribute) Sole constructor for this class.- Parameters:
parent- the parent this variable is part of, typically theConfigurationinstance, but in case of compounds/container also the containingIDecisionVariablevarDeclaration- 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
-
clear
void clear()Clears the list. -
getNestedElementsCount
public int getNestedElementsCount()Description copied from interface:IDecisionVariableReturns the number of nested elements. The return value should be 0 unless thisIDecisionVariableis a- Returns:
- An integer value greater or equal to 0.
-
getNestedElement
Description copied from interface:IDecisionVariableReturns the element specified byindex. [also req SAP]- Parameters:
index- a 0-based index specifying the element to be returned- Returns:
- the element
-
indexOf
Returns the 0-based index ofvarin this container.- Parameters:
var- the variable to search for- Returns:
- the index of
varor-1if not found
-
setValue
public void setValue(Value value, IAssignmentState state, IConfigurationElement nested) throws ConfigurationException Description copied from interface:IConfigurationElementChanges the value of a nested variable.- 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
-
setValue
Description copied from interface:IDecisionVariableChanges the value (for incremental buildup).- Specified by:
setValuein interfaceIDecisionVariable- Overrides:
setValuein classDecisionVariable- 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
-
freeze
Description copied from interface:IConfigurationElementCauses to freeze the current value.- Specified by:
freezein interfaceIConfigurationElement- Overrides:
freezein classDecisionVariable- Parameters:
selector- determines which parts shall be frozen
-
freeze
Description copied from interface:IConfigurationElementCauses to freeze a nested value.- Parameters:
nestedElement- The name of the nested Element, which should be frozen.
-
allowsNestedStates
boolean allowsNestedStates()Description copied from class:StructuredVariableReturns whether this variable support individual states for nested items.- Specified by:
allowsNestedStatesin classStructuredVariable- Returns:
trueif nested items can have their own states, otherwisefalse.
-
getElementName
Returns the symbolic name for an element in this container, such as the index for sequences.- Parameters:
index- the position of the element within the container- Returns:
- the symbolic name
-
addNestedElement
Adds a new nested element to this variable. This nested element is empty, is in stateAssignmentState.UNDEFINEDand can be configured afterwards.- Returns:
- the created decision variable
-
getContainedType
Returns the contained type of this container.- Returns:
- the contained type
-
addNestedElement
Adds a new nested element to this variable. This nested element is empty, is in stateAssignmentState.UNDEFINEDand can be configured afterwards.- Parameters:
type- the specific type to create the nested element for; if null, the declared contained type is used; if not assignable to the declared contained type, the declared contained type is used instead- Returns:
- the created decision variable
-
removeNestedElement
Removes a (configured) element (IDecisionVariable) of thisContainerVariable. This is the reverse function ofaddNestedElement().- Parameters:
var- A variable which is directly nested in this variable and shall be deleted.- Returns:
trueif the specified element was found and deleted from this variable,falseotherwise- See Also:
-
getState
Description copied from interface:IConfigurationElementReturns the assignment state of this variable.- Specified by:
getStatein interfaceIConfigurationElement- Overrides:
getStatein classDecisionVariable- Returns:
- the assignment state
-
addNestedElement
Adds a nestedIDecisionVariableto thisContainerVariable. If an equalIDecisionVariableis already part of thisContainerVariable, theIDecisionVariablewill be replaced by the new one.- Parameters:
var- The nestedIDecisionVariablewhich should be added to this container.
-
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.- Returns:
trueif there was a change,falseif the variable keeps unchanged.
-
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- Overrides:
notifyWasAssignedin classDecisionVariable- Parameters:
value- the new value- Returns:
truewhether this variable was defined before,falseelse
-