Package net.ssehub.easy.varModel.model
Class Project
java.lang.Object
net.ssehub.easy.varModel.model.ModelElement
net.ssehub.easy.varModel.model.Project
- All Implemented Interfaces:
net.ssehub.easy.basics.modelManagement.IModel,net.ssehub.easy.basics.modelManagement.IModelData,ICustomOperationAccessor,IResolutionScope,IAttributableElement,IAttributeAccess,IConstraintHolder,IFreezable,IModelElement
public class Project
extends ModelElement
implements net.ssehub.easy.basics.modelManagement.IModel, IAttributableElement, IResolutionScope, ICustomOperationAccessor, IFreezable, IConstraintHolder
This class holds the project imports, the containable model-, and attributable elements. Project is the top-level
element of each VarModel. Use
getVariable() for attributing a project.- Author:
- Marcel Lueder, Holger Eichelberger
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate StructuredCommentComments directly attached to this project (lazy initialization).private List<ProjectImport> private intprivate List<ContainableModelElement> private Map<String, ContainableModelElement> private Projectprivate longprivate ProjectTypeprivate DecisionVariableDeclarationStores the (pseudo) variable for this project.private net.ssehub.easy.basics.modelManagement.Version -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(IModelVisitor visitor) Accept method for the visitor.booleanadd(ContainableModelElement element) Method to add an object to the modelElement list of the project.private booleanadd(ContainableModelElement element, Supplier<Integer> position) Method to add an object to the modelElement list of the project.booleanadd(OperationDefinition definition) Method to add an operation definition to the modelElement list of the project.booleanaddBeforeFreeze(ContainableModelElement element) Method to add an object to the modelElement list of the project, but, if already contained, before the first freeze (assuming that freezes as usual are added to the end).voidaddConstraint(Constraint constraint) Adds a constraint.booleanaddImport(ProjectImport pimport) Adds an import to this project.booleanAttributes this element.voidclear()Removes the content of the project.booleancontainsByName(String name) Returns whether this project contains an element and its name.voiddispose()getAttribute(int index) Returns a specific attribute.getAttribute(String name) Returns a specific (declared) attribute.intReturns the number of (declared) attributes.getCommentBefore(IModelElement element, boolean ensureStructured) Returns the comment before the specified model element.Returns the structured comment for this project.getElement(int index) Returns a contained model element specified byindex.getElement(String name) Returns a contained model element specified by itsname.intReturns the number of contained elements.getImport(int index) Returns the project import specified byindex.intReturns the number of imports.net.ssehub.easy.basics.modelManagement.IndentationConfigurationReturns the indentation configuration for this model.longReturns the namespace introduced by this model element.getNestedComment(Object element) Returns a comment for anelementfrom within thegetComments().getOperation(int index) Returns the operation specified byindex.intReturns the number of operations.Returns the parent of this project.net.ssehub.easy.basics.modelManagement.IRestrictionEvaluationContextnet.ssehub.easy.basics.modelManagement.ModelImport<Project> getSuper()Returns the reference to the super model (if it exists).getType()Returns the (pseudo) datatype of this project.Returns the (pseudo) variable for this project.net.ssehub.easy.basics.modelManagement.VersionReturns the version of this project.booleanReturns whether this project has interfaces.booleanReturns whether this scope is an interfaces.booleanpropagateAttribute(Attribute attribute) Propagates an attribute application from the parent to this element or contained elements.booleanremove(OperationDefinition definition) Removes the given operation definition.booleanremoveElement(ContainableModelElement element) Removes the specified element from from this project.booleanremoveElements(List<ContainableModelElement> elementsToRemove) Removes all specified elements from this project.booleanremoveImport(ProjectImport pimport) Removes an import from this project.booleanrenameElement(String oldName, String newName) Renames an element.booleanrenameElement(ContainableModelElement elt, String newName) Renames an element.voidsetComments(StructuredComment comment) Sets a structured comment object for this project.(package private) voidChanges the parent of this project (intended to be used internally by the copy mechanism).voidsetVersion(net.ssehub.easy.basics.modelManagement.Version version) Changes the version of this project.voidSorts the contained elements according to the specified comparator.Methods inherited from class net.ssehub.easy.varModel.model.ModelElement
findAttribute, getComment, getName, getQualifiedName, getUniqueName, isTransparent, 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.IAttributableElement
getName, getQualifiedNameMethods inherited from interface net.ssehub.easy.varModel.model.IFreezable
getNameMethods inherited from interface net.ssehub.easy.basics.modelManagement.IModel
getNameMethods inherited from interface net.ssehub.easy.varModel.model.IModelElement
getComment, getName, getQualifiedName, getUniqueName, isTransparent, setCommentMethods inherited from interface net.ssehub.easy.varModel.model.datatypes.IResolutionScope
getName
-
Field Details
-
modelElements
-
version
private net.ssehub.easy.basics.modelManagement.Version version -
imports
-
type
-
interfaceCount
private int interfaceCount -
parent
-
names
-
timestamp
private long timestamp -
variable
Stores the (pseudo) variable for this project. We need this variable to attribute a project. -
comment
Comments directly attached to this project (lazy initialization).
-
-
Constructor Details
-
Project
Project()Constructor for serialization. -
Project
Constructor for the project.- Parameters:
name- Name of project
-
-
Method Details
-
addImport
Adds an import to this project. Conflicts are added always, imports are checked for duplicates.- Parameters:
pimport- The import- Returns:
trueif the addition was successful,falseelse due to duplicated names
-
removeImport
Removes an import from this project.- Parameters:
pimport- the import to be removed- Returns:
trueif the removal was successful,falseelse due to duplicated names
-
removeElements
Removes all specified elements from this project.- Parameters:
elementsToRemove- elements which should be removed. SeeConfiguration.toProject(false).- Returns:
trueif this project changed as a result of the call- See Also:
-
removeElement
Removes the specified element from from this project.- Parameters:
element- the element that should be removed. SeeConfiguration.toProject(false).- Returns:
trueif this project changed as a result of the call
-
clear
public void clear()Removes the content of the project. Removes:- All model elements
- All Internal constraints
- All Imports
-
getImportsCount
public int getImportsCount()Returns the number of imports.- Specified by:
getImportsCountin interfaceICustomOperationAccessor- Specified by:
getImportsCountin interfacenet.ssehub.easy.basics.modelManagement.IModel- Specified by:
getImportsCountin interfaceIResolutionScope- Returns:
- the number of imports
-
getImport
Returns the project import specified byindex.- Specified by:
getImportin interfaceICustomOperationAccessor- Specified by:
getImportin interfacenet.ssehub.easy.basics.modelManagement.IModel- Specified by:
getImportin interfaceIResolutionScope- Parameters:
index- a 0-based index specifying the import to be returned- Returns:
- the project import
- Throws:
IndexOutOfBoundsException- ifindex<0 || index>=getImportsCount()
-
setVersion
public void setVersion(net.ssehub.easy.basics.modelManagement.Version version) Changes the version of this project.- Specified by:
setVersionin interfacenet.ssehub.easy.basics.modelManagement.IModel- Parameters:
version- Version to set
-
getVersion
public net.ssehub.easy.basics.modelManagement.Version getVersion()Returns the version of this project.- Specified by:
getVersionin interfacenet.ssehub.easy.basics.modelManagement.IModel- Specified by:
getVersionin interfacenet.ssehub.easy.basics.modelManagement.IModelData- Returns:
- the version or
nullif no version is specified for this project.
-
getElement
Returns a contained model element specified byindex.- Specified by:
getElementin interfaceIResolutionScope- Parameters:
index- a 0-based index specifying the operation to be returned- Returns:
- the contained element
- Throws:
IndexOutOfBoundsException- ifindex<0 || index>=getElementCount()
-
getCommentBefore
Returns the comment before the specified model element.- Parameters:
element- the element to search forensureStructured- whether a default structured comment shall be inserted beforeelementif no comment was found- Returns:
- the comment assigned to
elementor null if none was found orensureStructuredis false, respectively
-
getElementCount
public int getElementCount()Returns the number of contained elements.- Specified by:
getElementCountin interfaceIResolutionScope- Returns:
- the number of contained elements
-
containsByName
Returns whether this project contains an element and its name.- Parameters:
name- the name to search for- Returns:
trueif this project contains the specified element,falseelse
-
getElement
Description copied from interface:IResolutionScopeReturns a contained model element specified by itsname.- Specified by:
getElementin interfaceIResolutionScope- Parameters:
name- the qualified or unqualified name to search for- Returns:
- the related element or null if no such element is known
-
addBeforeFreeze
Method to add an object to the modelElement list of the project, but, if already contained, before the first freeze (assuming that freezes as usual are added to the end). Only named elements are considered for checking duplicates!- Parameters:
element- which should be added- Returns:
trueif the addition was successful,falseelse due to duplicated names
-
add
Method to add an object to the modelElement list of the project. Only named elements are considered for checking duplicates!- Parameters:
element- which should be added- Returns:
trueif the addition was successful,falseelse due to duplicated names
-
add
Method to add an object to the modelElement list of the project. Only named elements are considered for checking duplicates!- Parameters:
element- element that should be addedposition- optional position provider function forList.add(int, Object), may be null for adding at end- Returns:
trueif the addition was successful,falseelse due to duplicated names
-
renameElement
Renames an element. UserenameVariablein configuration if a configuration is defined on this project.- Parameters:
elt- the element to be renamednewName- the new name- Returns:
trueif the element was found and renamed,falseelse
-
renameElement
Renames an element. UserenameVariablein configuration if a configuration is defined on this project.- Parameters:
oldName- the old namenewName- the new name- Returns:
trueif the element was found and renamed,falseelse
-
add
Method to add an operation definition to the modelElement list of the project.- Parameters:
definition- the operation definition which should be added- Returns:
trueif the addition was successful,falseelse due to duplicated names
-
remove
Removes the given operation definition.- Parameters:
definition- the definition to be removed- Returns:
trueif the operation was removed,falseelse
-
accept
Accept method for the visitor.- Specified by:
acceptin interfaceIFreezable- Specified by:
acceptin interfaceIModelElement- Parameters:
visitor- The visitor, which should process this model element.
-
getOperation
Returns the operation specified byindex.- Specified by:
getOperationin interfaceICustomOperationAccessor- Parameters:
index- a 0-based index specifying the operation to be returned- Returns:
- the operation
- Throws:
IndexOutOfBoundsException- ifindex<0 || index>=getOperationCount()
-
getOperationCount
public int getOperationCount()Returns the number of operations.- Specified by:
getOperationCountin interfaceICustomOperationAccessor- Returns:
- the number of operations
-
getType
Returns the (pseudo) datatype of this project. The returned type is intended to be used as the operand for custom operations to be added withadd(OperationDefinition).- Specified by:
getTypein interfaceICustomOperationAccessor- Specified by:
getTypein interfaceIFreezable- Returns:
- the datatype
-
getVariable
Returns the (pseudo) variable for this project. We need this variable to attribute a project.- Returns:
- the (pseudo) variable
-
hasInterfaces
public boolean hasInterfaces()Returns whether this project has interfaces.- Specified by:
hasInterfacesin interfaceIResolutionScope- Returns:
trueif it has interfaces,falseelse
-
attribute
Description copied from interface:IAttributableElementAttributes this element.- Specified by:
attributein interfaceIAttributableElement- Parameters:
attribute- the attribute to be added- Returns:
trueif the operation was successful,falseif the element is about being attributed multiple times with the same attribute
-
getAttributesCount
public int getAttributesCount()Description copied from interface:IAttributeAccessReturns the number of (declared) attributes.- Specified by:
getAttributesCountin interfaceIAttributeAccess- Returns:
- the number of attributes
-
getAttribute
Description copied from interface:IAttributeAccessReturns a specific (declared) attribute.- Specified by:
getAttributein interfaceIAttributeAccess- Parameters:
name- the name of the attribute- Returns:
- the attribute (or null if not found)
-
getAttribute
Description copied from interface:IAttributeAccessReturns a specific attribute.- Specified by:
getAttributein interfaceIAttributeAccess- Parameters:
index- the index of the attribute- Returns:
- the attribute
-
isInterface
public boolean isInterface()Description copied from interface:IResolutionScopeReturns whether this scope is an interfaces.- Specified by:
isInterfacein interfaceIResolutionScope- Returns:
trueif it is an interface,falseelse
-
getNameSpace
Description copied from interface:IModelElementReturns the namespace introduced by this model element.- Specified by:
getNameSpacein interfaceIModelElement- Overrides:
getNameSpacein classModelElement- Returns:
- the namespace introduced by this model element.
-
getParent
Returns the parent of this project.- Specified by:
getParentin interfaceIAttributeAccess- Specified by:
getParentin interfaceIFreezable- Specified by:
getParentin interfaceIModelElement- Specified by:
getParentin interfaceIResolutionScope- Overrides:
getParentin classModelElement- Returns:
- the parent of this project (in case of copied projects, may be null)
-
setParent
Changes the parent of this project (intended to be used internally by the copy mechanism).- Parameters:
parent- the new parent
-
setComments
Sets a structured comment object for this project.- Parameters:
comment- the comment object (may be null)
-
getComments
Returns the structured comment for this project.- Returns:
- structured comment instance
-
getNestedComment
Returns a comment for anelementfrom within thegetComments().- Parameters:
element- the element to return the comment for- Returns:
- the element, may be null
-
sortContainedElements
Sorts the contained elements 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.
- 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
-
getSuper
Returns the reference to the super model (if it exists).- Specified by:
getSuperin interfacenet.ssehub.easy.basics.modelManagement.IModel- Returns:
- always null as this does not exist in IVML
-
getIndentationConfiguration
public net.ssehub.easy.basics.modelManagement.IndentationConfiguration getIndentationConfiguration()Returns the indentation configuration for this model. The indentation configuration is considered to be immutable.- Specified by:
getIndentationConfigurationin interfacenet.ssehub.easy.basics.modelManagement.IModel- Returns:
- the indentation configuration (disabled if null)
-
dispose
public void dispose()- Specified by:
disposein interfacenet.ssehub.easy.basics.modelManagement.IModel
-
getRestrictionEvaluationContext
public net.ssehub.easy.basics.modelManagement.IRestrictionEvaluationContext getRestrictionEvaluationContext()- Specified by:
getRestrictionEvaluationContextin interfacenet.ssehub.easy.basics.modelManagement.IModel
-
addConstraint
Description copied from interface:IConstraintHolderAdds a constraint.- Specified by:
addConstraintin interfaceIConstraintHolder- Parameters:
constraint- the constraint to be added
-
getLastModification
public long getLastModification()- Specified by:
getLastModificationin interfacenet.ssehub.easy.basics.modelManagement.IModel
-