| /******************************************************************************* |
| * Copyright (c) 2004-2008 Andras Schmidt, Andras Balogh, Istvan Rath and Daniel Varro |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Andras Schmidt, Andras Balogh, Istvan Rath - initial API and implementation |
| *******************************************************************************/ |
| |
| package org.eclipse.viatra2.core; |
| |
| import java.util.Collection; |
| |
| /** |
| * This interface specifies the VPM core element representation |
| * |
| * @author Andras Balogh, Andras Schmidt, Istvan Rath |
| * |
| */ |
| public interface IModelElement extends Comparable<IModelElement> { |
| /** |
| * Gets the element's state. When you delete an element is changes state to |
| * deleted. Any action to the deleted element is corrupt, and must throw |
| * exception. |
| * |
| * @return true if the element is in the 'deleted' state |
| */ |
| public boolean isDeleted(); |
| |
| public boolean isEntity(); |
| |
| public boolean isRelation(); |
| |
| /** |
| * Gets the element's ID |
| * |
| * @return id |
| */ |
| public String getID(); |
| |
| /** |
| * Gets the element's name |
| * |
| * @return the name of the element |
| */ |
| public String getName(); |
| |
| /** |
| * Gets the element's view information |
| * |
| * @return the view information string of the element |
| */ |
| public String getViewInfo(); |
| |
| /** |
| * Gets the element's isFinalType flag |
| * |
| * @return true, if the model element cannot be subtyped |
| */ |
| public boolean getIsFinalType(); |
| |
| /** |
| * Returns the element's fully qualified name |
| * |
| * @return name |
| */ |
| public String getFullyQualifiedName(); |
| |
| /** |
| * Returns the collection of supertypes. |
| * |
| * @return the collection of supertypes |
| */ |
| public Collection<IModelElement> getSupertypes(); |
| |
| /** |
| * Gets the types of the element. The result set contains all Elements, |
| * which are instantiated by this Element. |
| * |
| * @return set of elements. |
| */ |
| public Collection<IModelElement> getTypes(); |
| |
| /** |
| * Gets the list of subtypes of the current Element. |
| * |
| * @return Set of elements |
| */ |
| public Collection<IModelElement> getSubtypes(); |
| |
| /** |
| * Gets all elements that are instances of the current one. |
| * |
| * @return collection of instances |
| */ |
| public Collection<IModelElement> getInstances(); |
| |
| /** |
| * Gets the String representation of this object. |
| */ |
| public String toString(); |
| |
| /** |
| * Gets recursively all supertypes of the current Element. |
| * |
| * @return set of Elements. |
| */ |
| public Collection<IModelElement> getAllSupertypes(); |
| |
| /** |
| * Gets recoursively all types of the current Element. |
| * |
| * @return set of Elements. |
| */ |
| public Collection<IModelElement> getAllTypes(); |
| |
| /** |
| * Gets recoursively all subtypes of the current element. |
| * |
| * @return set of types. |
| */ |
| public Collection<IModelElement> getAllSubtypes(); |
| |
| /** |
| * Gets recoursively all instances of the current element (and its |
| * subtypes). |
| * |
| * @return set of types. |
| */ |
| public Collection<IModelElement> getAllInstances(); |
| |
| /** |
| * Query the instanceof relation. |
| * |
| * @param type |
| * @return true if type is type of this, i.e.: |
| * A.isInstanceOf(B) true <=> B is a type of A |
| */ |
| public boolean isInstanceOf(IModelElement type); |
| |
| /** |
| * Query the supertypeof relation. |
| * |
| * @param sub |
| * @return true if sub is subtype of this, i.e.: |
| * A.isSupertypeOf(B) true <=> A is a supertype of B |
| */ |
| public boolean isSupertypeOf(IModelElement sub); |
| |
| /** |
| * Query the subtypeof relation. |
| * |
| * @param sup |
| * @return true if sup is supertype of this, i.e.: |
| * A.isSubtypeof(B) true <=> B is a supertype of A |
| */ |
| public boolean isSubtypeOf(IModelElement sup); |
| |
| /** |
| * Query the typeof relation. |
| * |
| * @param inst |
| * @return true if inst is type of this, i.e.: |
| * A.isTypeOf(B) true <=> A is a type of B |
| */ |
| public boolean isTypeOf(IModelElement inst); |
| |
| /** |
| * Query the typeof relation. |
| * |
| * @param inst |
| * @return true if inst is direct instance of this, i.e.: |
| * A.isDirectTypeOf(B) true <=> A is a direct type (without transitivity) of B |
| */ |
| public boolean isDirectTypeOf(IModelElement inst); |
| |
| /** |
| * Query the subtypeof relation. |
| * |
| * @param inst |
| * @return true if sup is direct supertype of this, i.e.: |
| * A.isDirectSubtypeOf(B) true <=> B is a direct supertype of A |
| */ |
| public boolean isDirectSubtypeOf(IModelElement sup); |
| |
| /** |
| * Query the subtypeof relation. |
| * |
| * @param inst |
| * @return true if sup is direct subtype of this, i.e.: |
| * A.isDirectSupertypeOf(B) true <=> A is a direct supertype of B |
| */ |
| public boolean isDirectSupertypeOf(IModelElement sub); |
| |
| /** |
| * Query the instanceof relation. |
| * |
| * @param inst |
| * @return true if type is direct type of this |
| * A.isDirectInstanceOf(B) true <=> B is a direct type of A |
| */ |
| public boolean isDirectInstanceOf(IModelElement type); |
| |
| /** |
| * Query the modelspace that contains this element |
| * |
| * @return the modelspace that contains this element |
| */ |
| public IModelSpace getModelSpace(); |
|
|
| /** |
| * Returns all relations, which end at this entity |
| * |
| * @return |
| */ |
| public Collection<IRelation> getRelationsTo(); |
| |
| /** |
| * Returns all relations, which start at this entity |
| * |
| * @return |
| */ |
| public Collection<IRelation> getRelationsFrom(); |
| |
| /** |
| * Returns one relation, which ends at this entity and has type type |
| * |
| * @param type |
| * @return |
| */ |
| public IRelation getRelationToByType(IModelElement type); |
| |
| /** |
| * Returns one relation, which starts at this entity and has type type |
| * |
| * @param type |
| * @return |
| */ |
| public IRelation getRelationFromByType(IModelElement type); |
| |
| /** |
| * Returns one relation, which ends at this entity and has name name |
| * |
| * @param name |
| * @return |
| */ |
| public IRelation getRelationToByName(String name); |
| |
| /** |
| * Returns one relation, which starts at this entity and has name name |
| * |
| * @param name |
| * @return |
| */ |
| public IRelation getRelationFromByName(String name); |
| |
| /** |
| * Returns all relations associated with this entity |
| * |
| * @return collection of relations |
| */ |
| public Collection<IRelation> getRelations(); |
| |
| /** |
| * Returns the first connection for a given name |
| * |
| * @param n |
| * then name of the connection |
| * @return The coresponding relation |
| */ |
| // public IRelation getConnectionByName(String n);
|
| /** |
| * Returns the connection from the element for a given name |
| * |
| * @param n |
| * then name of the connection |
| * @return The coresponding relation |
| */ |
| // public IRelation getConnectionFromByName(String n);
|
| /** |
| * Returns the first connection for a given type |
| * |
| * @param n |
| * then name of the connection |
| * @return The coresponding relation |
| */ |
| // public IRelation getConnectionByType(IModelElement n);
|
| /** |
| * Returns the first connection for a given type starting from the entity |
| * |
| * @param n |
| * then name of the connection |
| * @return The coresponding relation |
| */ |
| // public IRelation getConnectionFromByType(IRelation n);
|
| /** |
| * Returns the first relation for a given name |
| * |
| * @param n |
| * then name of the relation |
| * @return The coresponding relation |
| */ |
| public IRelation getRelationByName(String n); |
| |
| /** |
| * Returns the first relation for a given type |
| * |
| * @param n |
| * then name of the relation |
| * @return The coresponding relation |
| */ |
| public IRelation getRelationByType(IModelElement n); |
| |
| public IModelElement getRelationTargetByType(IRelation type); |
| |
| /** |
| * Returns all connection target which is conected via a relation with the |
| * specified type |
| * |
| * @param type |
| * the relation type |
| * @return set of appropriate model elements. |
| */ |
| public Collection<IModelElement> getAllRelationTargetByType(IRelation type); |
| |
| /** |
| * Returns the first connection source which is connected via a relation of |
| * the specified type. |
| * |
| * @param type |
| * The relation type. |
| * @return the first appropriate connection if found, null otherwise. |
| */ |
| public IModelElement getRelationSourceByType(IRelation type); |
| |
| /** |
| * Gets all relations starting at this element conforming to the type. |
| * @param type |
| * @return |
| */ |
| public Collection<IRelation> getAllRelationFromByType(IRelation type); |
| |
| /** |
| * Gets all relations ending at this element conforming to type. |
| * @param type |
| * @return |
| */ |
| public Collection<IRelation> getAllRelationToByType(IRelation type); |
| |
| /** |
| * Returns all connection source which is connected via a relation with the |
| * specified type |
| * |
| * @param type |
| * the relation type |
| * @return set of appropriate model elements. |
| */ |
| public Collection<IModelElement> getAllRelationSourceByType(IRelation type); |
| |
| /** |
| * Get the modelelement that has this one in its namespace. parent for |
| * entity, source for relation |
| * |
| * @return namespace, or null for root. |
| */ |
| public IModelElement getNamespace(); |
| |
| /** |
| * Returns whether the model element is below grandpa in namaspace hierarcy. |
| * |
| * @param grandpa |
| * @return |
| */ |
| public boolean isBelowNamespace(IModelElement grandpa); |
| |
| /** |
| * Find element with given name in the namespace of this element (child |
| * entity or relation from this element) |
| * |
| * @param name |
| * element's name to be found |
| * @return element with name below this element or null if element with name |
| * is not present |
| */ |
| public IModelElement getElementInNamespaceByName(String name); |
| |
| /** |
| * Find all element in the namespace of this element (child entity or |
| * relation from this element) |
| * |
| * @return all elements in namespace of this element |
| */ |
| public Collection<IModelElement> getElementsInNamespace(); |
| |
| /** |
| * Returns the transitive closure of the namespace (all elements below). |
| */ |
| public Collection<IModelElement> getAllElementsInNamespace(); |
| |
| /** |
| * Find all elemetns which are in the required relation with this element. |
| * This method is a reflection method for many query methods. |
| * |
| * @param relationType |
| * @return collection of elements |
| */ |
| // public Collection<IModelElement> getElementsInRelation(EConstraint relationType); |
| |
| } |