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
public abstract class ContainerVariable extends StructuredVariable
VariableConfigProviderfor nested variables of aContainerVariable.- Author:
- El-Sharkawy
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<IDecisionVariable>nestedElements
-
Constructor Summary
Constructors Modifier Constructor Description protectedContainerVariable(IConfigurationElement parent, AbstractVariable varDeclaration, boolean isVisible, boolean isAttribute)Sole constructor for this class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IDecisionVariableaddNestedElement()Adds a new nested element to this variable.(package private) voidaddNestedElement(IDecisionVariable var)Adds a nestedIDecisionVariableto thisContainerVariable.IDecisionVariableaddNestedElement(IDatatype type)Adds a new nested element to this variable.(package private) booleanallowsNestedStates()Returns whether this variable support individual states for nested items.(package private) voidclear()Clears the list.voidfreeze(java.lang.String nestedElement)Causes to freeze a nested value.voidfreeze(IFreezeSelector selector)Causes to freeze the current value.IDatatypegetContainedType()Returns the contained type of this container.protected java.lang.StringgetElementName(int index)Returns the symbolic name for an element in this container, such as the index for sequences.IDecisionVariablegetNestedElement(int index)Returns the element specified byindex.intgetNestedElementsCount()Returns the number of nested elements.IAssignmentStategetState()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 throughCommandAssignmentState#compareTo(CommandAssignmentState).booleanremoveDerivedValues()Removes all (nested) values which are in stateAssignmentState.DERIVED, i.e., all values which are propagated bay the reasoner.booleanremoveNestedElement(IDecisionVariable var)Removes 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 Detail
-
nestedElements
private java.util.List<IDecisionVariable> nestedElements
-
-
Constructor Detail
-
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 Detail
-
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
public IDecisionVariable getNestedElement(int index)
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
public int indexOf(IDecisionVariable var)
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
public void setValue(Value value, IAssignmentState state) throws ConfigurationException
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
public void freeze(IFreezeSelector selector)
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
public void freeze(java.lang.String nestedElement)
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:
- true if nested items can have their own states, otherwise false.
-
getElementName
protected java.lang.String getElementName(int index)
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
public IDecisionVariable 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
public IDatatype getContainedType()
Returns the contained type of this container.- Returns:
- the contained type
-
addNestedElement
public IDecisionVariable addNestedElement(IDatatype type)
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
public boolean removeNestedElement(IDecisionVariable var)
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:
- true if the specified element was found and deleted from this variable, false otherwise
- See Also:
addNestedElement()
-
getState
public IAssignmentState getState()
Description copied from interface:IConfigurationElementReturns the assignment state of this variable.- Specified by:
getStatein interfaceIConfigurationElement- Overrides:
getStatein classDecisionVariable- Returns:
- the assignment state
-
addNestedElement
void addNestedElement(IDecisionVariable var)
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:
- true if there was a change, false if the variable keeps unchanged.
-
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- Overrides:
notifyWasAssignedin classDecisionVariable- Parameters:
value- the new value- Returns:
truewhether this variable was defined before,falseelse
-
-