Class CompoundVariable
java.lang.Object
net.ssehub.easy.varModel.confModel.DecisionVariable
net.ssehub.easy.varModel.confModel.StructuredVariable
net.ssehub.easy.varModel.confModel.CompoundVariable
- All Implemented Interfaces:
IConfigurationElement,IConfigurationVisitable,IDecisionVariable,IValueParent
Class for variables of Compounds.
- Author:
- El-Sharkawy
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate Compoundprivate Map<String, IDecisionVariable> -
Constructor Summary
ConstructorsConstructorDescriptionCompoundVariable(IConfigurationElement parent, AbstractVariable varDeclaration, boolean isVisible, boolean isAttribute) Sole constructor for creatingContainerVariable's. -
Method Summary
Modifier and TypeMethodDescription(package private) booleanReturns whether this variable support individual states for nested items.private IDecisionVariablecreateNestedElement(AbstractVariable decl, boolean isVisible, boolean isAttribute, boolean force) Creates a nested element due to its declaration and registers it.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.Returns one of the actual types required to instantiate this variable.protected net.ssehub.easy.basics.logger.EASyLoggerFactory.EASyLoggerReturns the logger for this instance.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 a nestedIDecisionVariable.protected IResolutionPathElementReturns the resolution path for a nested element.getState()Returns the assignment state of this variable.getValue()Returns the current value of thisIDecisionVariable.private booleanReturns whetherslothas a directly recursive type (same or somehow refined) to the containing type.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).booleanRemoves all (nested) values which are in stateAssignmentState.DERIVED, i.e., all values which are propagated bay the reasoner.private voidresolveAssignBlocks(AttributeAssignment assignBlock, Map<String, Value> annotationValues) Second recursive part ofresolveAssignBlocks(Compound), find (nested assign blocks) inside the currently visited compound and set values to the associatedIDecisionVariables.private voidresolveAssignBlocks(Compound cType) Recursive part of the constructor to resolve annotation assignment blocks of (parent/this) compound.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.voidunfreeze(IAssignmentState state) Causes to unfreeze the current value.booleanReturns whether the variable value was explicitly created.Methods inherited from class net.ssehub.easy.varModel.confModel.DecisionVariable
accept, getAttribute, getAttributesCount, getConfigProvider, getConfiguration, getDeclaration, getNestedDepth, getParent, getQualifiedName, getResolutionPath, hasNullValue, hasValue, isAttribute, isLocal, isNested, isVisible, ownStateAllowed, setHistoryValue, setIndex, setState, setValue, toString, wasAssigned
-
Field Details
-
nestedElements
-
instantiatableType
-
created
private boolean created
-
-
Constructor Details
-
CompoundVariable
CompoundVariable(IConfigurationElement parent, AbstractVariable varDeclaration, boolean isVisible, boolean isAttribute) Sole constructor for creatingContainerVariable's.- 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
-
getInstantiatableType
Description copied from class:DecisionVariableReturns 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.- Overrides:
getInstantiatableTypein classDecisionVariable- Returns:
- the instantiatable type
-
resolveAssignBlocks
Recursive part of the constructor to resolve annotation assignment blocks of (parent/this) compound.- Parameters:
cType- The currently analyzed compound (should be called the (refined) compound type of this variable instance).
-
resolveAssignBlocks
private void resolveAssignBlocks(AttributeAssignment assignBlock, Map<String, Value> annotationValues) Second recursive part ofresolveAssignBlocks(Compound), find (nested assign blocks) inside the currently visited compound and set values to the associatedIDecisionVariables.- Parameters:
assignBlock- The currently visited assign block (start with assign blocks directly nested inside the compound).annotationValues- Mapping of (annotation name, value). Start with an empty map and copy values into a new map for each recursive call.
-
isDirectTypeRecursive
Returns whetherslothas a directly recursive type (same or somehow refined) to the containing type.- Parameters:
slot- the slot to look for- Returns:
truein case of a directly recursive type,falseelse
-
createNestedElement
private IDecisionVariable createNestedElement(AbstractVariable decl, boolean isVisible, boolean isAttribute, boolean force) Creates a nested element due to its declaration and registers it.- Parameters:
decl- the variable declarationisVisible- specifies whether the parent variable is exported by an interface or notisAttribute- whether this variable represents (a part of) an attribute or a variableforce- enforce creation of nested element even ifisDirectTypeRecursive(AbstractVariable)- Returns:
- the created variable, null if creation did not happen or failed (see log)
-
getState
Description copied from interface:IConfigurationElementReturns the assignment state of this variable.- Specified by:
getStatein interfaceIConfigurationElement- Overrides:
getStatein classDecisionVariable- Returns:
- the assignment state
-
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
-
getNestedElement
Description copied from interface:IDecisionVariableReturns an element specified by its name.- Specified by:
getNestedElementin interfaceIDecisionVariable- Overrides:
getNestedElementin classDecisionVariable- Parameters:
name- the name of the nested element- Returns:
- the nested element (may be null)
-
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
Changes the value (for incremental buildup).
Sets also the states for the nested elements.- 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
-
getNestedVariable
Returns a nestedIDecisionVariable.- Parameters:
slotName- The name of the nestedIDecisionVariableto be returned.- Returns:
- The nested
IDecisionVariablewith the same name or null.
-
freeze
Description copied from interface:IConfigurationElementCauses to freeze a nested value.- Parameters:
nestedElement- The name of the nested Element, which should be frozen.
-
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
-
unfreeze
Description copied from interface:IConfigurationElementCauses to unfreeze the current value.- Specified by:
unfreezein interfaceIConfigurationElement- Overrides:
unfreezein classDecisionVariable- Parameters:
state- the target state for unfreezing (must not beAssignmentState.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.
-
getValue
Description copied from interface:IDecisionVariableReturns the current value of thisIDecisionVariable.- Specified by:
getValuein interfaceIDecisionVariable- Overrides:
getValuein classDecisionVariable- Returns:
- the value (may be null)
-
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.
-
getPathForNestedElement
Returns the resolution path for a nested element.- Overrides:
getPathForNestedElementin classDecisionVariable- Parameters:
nested- the nested element- Returns:
- the resolution path
-
getLogger
protected net.ssehub.easy.basics.logger.EASyLoggerFactory.EASyLogger getLogger()Returns the logger for this instance.- Returns:
- the logger
-
notifyCreated
public void notifyCreated()Description copied from interface:IDecisionVariableNotifies this variable that it was created.- Specified by:
notifyCreatedin interfaceIDecisionVariable- Overrides:
notifyCreatedin classDecisionVariable
-
wasCreated
public boolean wasCreated()Description copied from interface:IConfigurationElementReturns whether the variable value was explicitly created.- Specified by:
wasCreatedin interfaceIConfigurationElement- Overrides:
wasCreatedin classDecisionVariable- Returns:
truefor created,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- Overrides:
enableWasAssignedForIsDefinedin classDecisionVariable- Returns:
truetakeIDecisionVariable.wasAssigned(),falseforIConfigurationElement.getState().
-
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
-