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 Classes Modifier and Type Class Description static classAttributeAssignment.AssignmentCharacterizes an attribute-value assignment.
-
Field Summary
Fields Modifier and Type Field Description private BasicDecisionVariableContainercontainerprivate java.util.List<AttributeAssignment.Assignment>data
-
Constructor Summary
Constructors Constructor Description AttributeAssignment()Constructor for serialization.AttributeAssignment(IModelElement parent)Creates a new attribute assignment.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(IModelVisitor visitor)Accept method for the visitor.voidadd(AttributeAssignment assignment)Adds a nested assignment.voidadd(AttributeAssignment.Assignment assignment)Adds an individual assignment.voidadd(Comment comment)Adds a comment to the list of contained elements.booleanadd(DecisionVariableDeclaration elem)Method 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.booleancontains(DecisionVariableDeclaration var)Returns whether this element containsvar.booleancontainsByName(java.lang.String name)Returns whether this project contains an element and its name.voidforceUpdate()Forces theIDecisionVariableContainerto update cached lists of nestedDecisionVariableDeclarations.AttributeAssignmentgetAssignment(int index)Returns the assignment specified byindex.intgetAssignmentCount()Returns the number of assignments.AttributeAssignment.AssignmentgetAssignmentData(int index)Returns the specified assignment data instance.intgetAssignmentDataCount()Returns the number of assignment data instances (attribute-value combinations).ConstraintgetConstraint(int index)Returns the specified contained constraint.intgetConstraintsCount()Returns the number of contained constraints.DecisionVariableDeclarationgetDeclaration(int index)Returns the specifiedDecisionVariableDeclaration.intgetDeclarationCount()Returns the number of all nestedDecisionVariableDeclarations including nestedDecisionVariableDeclarations ofAttributeAssignments.IModelElementgetEffectiveParent()Returns the effective parent of this assignment, i.e., the containing compound or project.DecisionVariableDeclarationgetElement(int index)Returns the element specified byindex.DecisionVariableDeclarationgetElement(java.lang.String name)Returns the element specified byname.intgetElementCount()Returns the number of elements.ContainableModelElementgetModelElement(int index)Returns a contained model element specified byindex.intgetModelElementCount()Returns the number of contained elements.ConstraintgetRealizing(int index)Returns the specified realizing constraint.intgetRealizingCount()Returns the number of realizing constraints.booleanisTransparent()Returns 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.voidsortContainedElements(java.util.Comparator<ContainableModelElement> comp)Sorts 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, setParent
-
Methods inherited from class net.ssehub.easy.varModel.model.ModelElement
findAttribute, getComment, getName, getUniqueName, setComment, setName, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.ssehub.easy.varModel.model.IModelElement
getComment, getName, getNameSpace, getParent, getQualifiedName, getUniqueName, setComment
-
-
-
-
Field Detail
-
data
private java.util.List<AttributeAssignment.Assignment> data
-
container
private BasicDecisionVariableContainer container
-
-
Constructor Detail
-
AttributeAssignment
AttributeAssignment()
Constructor for serialization.
-
AttributeAssignment
public AttributeAssignment(IModelElement parent)
Creates a new attribute assignment.- Parameters:
parent- the model element, in which this specific one is embedded
-
-
Method Detail
-
accept
public void accept(IModelVisitor visitor)
Description copied from interface:IModelElementAccept method for the visitor.- Specified by:
acceptin interfaceIModelElement- Parameters:
visitor- The visitor, which should process this model element.
-
getEffectiveParent
public IModelElement 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
public AttributeAssignment.Assignment getAssignmentData(int index)
Returns the specified assignment data instance.- Parameters:
index- the index of the assignment to be returned- Returns:
- the specified assignment
- Throws:
java.lang.IndexOutOfBoundsException- ifindex < 0 || index >=getAssignmentCount()
-
add
public boolean add(DecisionVariableDeclaration elem)
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
public void add(AttributeAssignment.Assignment assignment)
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
public DecisionVariableDeclaration getElement(java.lang.String name)
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
public boolean contains(DecisionVariableDeclaration var)
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
public DecisionVariableDeclaration getElement(int index)
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
public Constraint getConstraint(int index)
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
public Constraint getRealizing(int index)
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
public void add(Comment comment)
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
public void add(AttributeAssignment assignment)
Description copied from interface:IDecisionVariableContainerAdds a nested assignment.- Specified by:
addin interfaceIDecisionVariableContainer- Parameters:
assignment- the assignment which should be added
-
addConstraint
public void addConstraint(Constraint constraint, boolean internal)
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
public AttributeAssignment getAssignment(int index)
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
public ContainableModelElement getModelElement(int index)
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
public void sortContainedElements(java.util.Comparator<ContainableModelElement> comp)
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
public boolean propagateAttribute(Attribute attribute)
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
public DecisionVariableDeclaration getDeclaration(int index)
Description copied from interface:IDecisionVariableContainerReturns the specifiedDecisionVariableDeclaration.- Specified by:
getDeclarationin interfaceIDecisionVariableContainer- Parameters:
index- the index of theDecisionVariableDeclarationto be returned- Returns:
- the specified
DecisionVariableDeclaration
-
add
public void add(EvaluationBlock eval)
Description copied from interface:IDecisionVariableContaineradds a nested evaluation block.- Specified by:
addin interfaceIDecisionVariableContainer- Parameters:
eval- the eval block
-
containsByName
public boolean containsByName(java.lang.String name)
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
-
-