Package net.ssehub.easy.varModel.model
Class AttributeAssignment
java.lang.Object
net.ssehub.easy.varModel.model.ModelElement
net.ssehub.easy.varModel.model.ContainableModelElement
net.ssehub.easy.varModel.model.AttributeAssignment
- All Implemented Interfaces:
IContainableElementsSorter,IDatatypeVisitable,IDecisionVariableContainer,IModelElement
public class AttributeAssignment
extends ContainableModelElement
implements IDecisionVariableContainer
Represents an assignment of a value to attributes of at least
one model element.
So far we refrained from defining (multiple) recursive iterators (over the assignments) due to different style and
potential performance issues of the generic code.
- Author:
- Holger Eichelberger
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classCharacterizes an attribute-value assignment. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate BasicDecisionVariableContainerprivate List<AttributeAssignment.Assignment> -
Constructor Summary
ConstructorsConstructorDescriptionConstructor for serialization.AttributeAssignment(IModelElement parent) Creates a new attribute assignment. -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(IModelVisitor visitor) Accept method for the visitor.voidadd(AttributeAssignment assignment) Adds a nested assignment.voidadd(AttributeAssignment.Assignment assignment) Adds an individual assignment.voidAdds a comment to the list of contained elements.booleanMethod to add an object to the elements list of the project.voidadd(EvaluationBlock eval) adds a nested evaluation block.voidaddConstraint(Constraint constraint, boolean internal) Adds a constraint.booleanReturns whether this element containsvar.booleancontainsByName(String name) Returns whether this project contains an element and its name.voidForces theIDecisionVariableContainerto update cached lists of nestedDecisionVariableDeclarations.getAssignment(int index) Returns the assignment specified byindex.intReturns the number of assignments.getAssignmentData(int index) Returns the specified assignment data instance.intReturns the number of assignment data instances (attribute-value combinations).getConstraint(int index) Returns the specified contained constraint.intReturns the number of contained constraints.getDeclaration(int index) Returns the specifiedDecisionVariableDeclaration.intReturns the number of all nestedDecisionVariableDeclarations including nestedDecisionVariableDeclarations ofAttributeAssignments.Returns the effective parent of this assignment, i.e., the containing compound or project.getElement(int index) Returns the element specified byindex.getElement(String name) Returns the element specified byname.intReturns the number of elements.getModelElement(int index) Returns a contained model element specified byindex.intReturns the number of contained elements.getRealizing(int index) Returns the specified realizing constraint.intReturns the number of realizing constraints.booleanReturns whether this element is transparent regarding the naming hierarchy.booleanpropagateAttribute(Attribute attribute) Propagates an attribute application from the parent to this element or contained elements.voidSorts the contained elements (and creates the related datastructure if needed) according to the specified comparator.Methods inherited from class net.ssehub.easy.varModel.model.ContainableModelElement
accept, getNameSpace, getParent, getProject, getQualifiedName, getTopLevelParent, isTopLevel, setParentMethods inherited from class net.ssehub.easy.varModel.model.ModelElement
findAttribute, getComment, getName, getUniqueName, setComment, setName, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface net.ssehub.easy.varModel.model.IModelElement
getComment, getName, getNameSpace, getParent, getQualifiedName, getUniqueName, setComment
-
Field Details
-
data
-
container
-
-
Constructor Details
-
AttributeAssignment
AttributeAssignment()Constructor for serialization. -
AttributeAssignment
Creates a new attribute assignment.- Parameters:
parent- the model element, in which this specific one is embedded
-
-
Method Details
-
accept
Description copied from interface:IModelElementAccept method for the visitor.- Specified by:
acceptin interfaceIModelElement- Parameters:
visitor- The visitor, which should process this model element.
-
getEffectiveParent
Returns the effective parent of this assignment, i.e., the containing compound or project.- Returns:
- the effective parent (null if there is none)
-
getAssignmentDataCount
public int getAssignmentDataCount()Returns the number of assignment data instances (attribute-value combinations).- Returns:
- the number of assignment instances
-
getAssignmentData
Returns the specified assignment data instance.- Parameters:
index- the index of the assignment to be returned- Returns:
- the specified assignment
- Throws:
IndexOutOfBoundsException- ifindex < 0 || index >=getAssignmentCount()
-
add
Description copied from interface:IDecisionVariableContainerMethod to add an object to the elements list of the project.- Specified by:
addin interfaceIDecisionVariableContainer- Parameters:
elem- which should be added- Returns:
trueif the addition was successful,falseelse due to duplicated variable declaration
-
add
Adds an individual assignment.- Parameters:
assignment- the assignment to be added
-
isTransparent
public boolean isTransparent()Description copied from interface:IModelElementReturns whether this element is transparent regarding the naming hierarchy.- Specified by:
isTransparentin interfaceIModelElement- Overrides:
isTransparentin classModelElement- Returns:
trueif it is transparent,falseelse
-
getElementCount
public int getElementCount()Description copied from interface:IDecisionVariableContainerReturns the number of elements.- Specified by:
getElementCountin interfaceIDecisionVariableContainer- Returns:
- the number of elements
-
getElement
Description copied from interface:IDecisionVariableContainerReturns the element specified byname.- Specified by:
getElementin interfaceIDecisionVariableContainer- Parameters:
name- the name of the element- Returns:
- the element, null if none was found
-
contains
Description copied from interface:IDecisionVariableContainerReturns whether this element containsvar.- Specified by:
containsin interfaceIDecisionVariableContainer- Parameters:
var- the variable declaration to search for- Returns:
trueif found,falseelse
-
getElement
Description copied from interface:IDecisionVariableContainerReturns the element specified byindex.- Specified by:
getElementin interfaceIDecisionVariableContainer- Parameters:
index- a 0-based index specifying the element to be returned- Returns:
- the element
-
getConstraintsCount
public int getConstraintsCount()Description copied from interface:IDecisionVariableContainerReturns the number of contained constraints.- Specified by:
getConstraintsCountin interfaceIDecisionVariableContainer- Returns:
- the number of constraints
-
getConstraint
Description copied from interface:IDecisionVariableContainerReturns the specified contained constraint.- Specified by:
getConstraintin interfaceIDecisionVariableContainer- Parameters:
index- the index of the constraint to be returned- Returns:
- the specified constraint
-
getRealizingCount
public int getRealizingCount()Description copied from interface:IDecisionVariableContainerReturns the number of realizing constraints. Please note that these constraints are derived and not originally specified in the input IVML model.- Specified by:
getRealizingCountin interfaceIDecisionVariableContainer- Returns:
- the number of constraints
-
getRealizing
Description copied from interface:IDecisionVariableContainerReturns the specified realizing constraint. Please note that these constraints are derived and not originally specified in the input IVML model.- Specified by:
getRealizingin interfaceIDecisionVariableContainer- Parameters:
index- the index of the constraint to be returned- Returns:
- the specified constraint
-
add
Description copied from interface:IDecisionVariableContainerAdds a comment to the list of contained elements.- Specified by:
addin interfaceIDecisionVariableContainer- Parameters:
comment- the comment to be added
-
add
Description copied from interface:IDecisionVariableContainerAdds a nested assignment.- Specified by:
addin interfaceIDecisionVariableContainer- Parameters:
assignment- the assignment which should be added
-
addConstraint
Description copied from interface:IDecisionVariableContainerAdds a constraint.- Specified by:
addConstraintin interfaceIDecisionVariableContainer- Parameters:
constraint- the constraint to be addedinternal- whether the constraint is internally created while building up the model (ignored)
-
getAssignmentCount
public int getAssignmentCount()Description copied from interface:IDecisionVariableContainerReturns the number of assignments.- Specified by:
getAssignmentCountin interfaceIDecisionVariableContainer- Returns:
- the number of assignments
-
getAssignment
Description copied from interface:IDecisionVariableContainerReturns the assignment specified byindex.- Specified by:
getAssignmentin interfaceIDecisionVariableContainer- Parameters:
index- a 0-based index specifying the element to be returned- Returns:
- the assignment
-
getModelElement
Description copied from interface:IDecisionVariableContainerReturns a contained model element specified byindex. Please note that this method returns all contained model elements, i.e., decision variables and constraints and is intended to restore the input sequence correctly.- Specified by:
getModelElementin interfaceIDecisionVariableContainer- Parameters:
index- a 0-based index specifying the operation to be returned- Returns:
- the contained element
-
getModelElementCount
public int getModelElementCount()Description copied from interface:IDecisionVariableContainerReturns the number of contained elements. Please note that this method refers to all contained model elements, i.e., decision variables and constraints and is intended to restore the input sequence correctly.- Specified by:
getModelElementCountin interfaceIDecisionVariableContainer- Returns:
- the number of contained elements
-
sortContainedElements
Description copied from interface:IContainableElementsSorterSorts the contained elements (and creates the related datastructure if needed) according to the specified comparator. Please note the following requirements for applying this method:- All Elements which were added before this operation must still be member of this project after executing this operation.
- Comments related to an element must occur before the element in the final sequence.
- Specified by:
sortContainedElementsin interfaceIContainableElementsSorter- Parameters:
comp- a comparator which fulfills the requirements above
-
propagateAttribute
Description copied from interface:IModelElementPropagates an attribute application from the parent to this element or contained elements. This may imply the creation of clones of the givenattribute.- Specified by:
propagateAttributein interfaceIModelElement- Overrides:
propagateAttributein classModelElement- Parameters:
attribute- the attribute to be propagated- Returns:
trueif the operation was successful,falseif the element is about being attributed multiple times with the same attribute
-
getDeclarationCount
public int getDeclarationCount()Description copied from interface:IDecisionVariableContainerReturns the number of all nestedDecisionVariableDeclarations including nestedDecisionVariableDeclarations ofAttributeAssignments.- Specified by:
getDeclarationCountin interfaceIDecisionVariableContainer- Returns:
- The number of all nested
DecisionVariableDeclarations. This will be greater or equal to 0.
-
getDeclaration
Description copied from interface:IDecisionVariableContainerReturns the specifiedDecisionVariableDeclaration.- Specified by:
getDeclarationin interfaceIDecisionVariableContainer- Parameters:
index- the index of theDecisionVariableDeclarationto be returned- Returns:
- the specified
DecisionVariableDeclaration
-
add
Description copied from interface:IDecisionVariableContaineradds a nested evaluation block.- Specified by:
addin interfaceIDecisionVariableContainer- Parameters:
eval- the eval block
-
containsByName
Description copied from interface:IDecisionVariableContainerReturns whether this project contains an element and its name.- Specified by:
containsByNamein interfaceIDecisionVariableContainer- Parameters:
name- the name to search for- Returns:
trueif this project contains the specified element,falseelse
-
forceUpdate
public void forceUpdate()Description copied from interface:IDecisionVariableContainerForces theIDecisionVariableContainerto update cached lists of nestedDecisionVariableDeclarations. This is only necessary if multipleIDecisionVariableContainerare nested into each other and only during incremental build up if an inner element is updated while already added to the outer element.- Specified by:
forceUpdatein interfaceIDecisionVariableContainer
-