protected static EList<Interface> getRequiredInterfaces( ConnectableElement connectableElement) { EList<Interface> requiredInterfaces = new UniqueEList.FastCompare<Interface>(); if (connectableElement instanceof Port) { requiredInterfaces.addAll(((Port) connectableElement) .getRequireds()); } else if (connectableElement instanceof Property) { Type type = connectableElement.getType(); if (type instanceof Component) { ComponentOperations.getAllRequireds((Component) type, requiredInterfaces); } else if (type instanceof Classifier) { Classifier classifier = (Classifier) type; ComponentOperations.usedInterfaces(null, classifier, true, requiredInterfaces); for (Classifier parent : classifier.allParents()) { ComponentOperations.usedInterfaces(null, parent, true, requiredInterfaces); } } } for (int i = 0, size = requiredInterfaces.size(); i < size; i++) { for (Classifier parent : requiredInterfaces.get(i).allParents()) { if (parent instanceof Interface) { requiredInterfaces.add((Interface) parent); } } } return ECollections.unmodifiableEList(requiredInterfaces); }
/** * Creates an instance that is a copy of the collection, with duplicates removed. * @param collection the initial contents of the list. */ public FastCompare(Collection<? extends E> collection) { super(collection.size()); addAll(collection); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * <!-- begin-model-doc --> * The query importMembers() defines which of a set of PackageableElements are actually imported into the namespace. This excludes hidden ones, i.e., those which have names that conflict with names of owned members, and also excludes elements which would have the same name when imported. * result = self.excludeCollisions(imps)->select(imp | self.ownedMember->forAll(mem | * mem.imp.isDistinguishableFrom(mem, self))) * @param namespace The receiving '<em><b>Namespace</b></em>' model object. * <!-- end-model-doc --> * @generated NOT */ public static EList<PackageableElement> importMembers(Namespace namespace, EList<PackageableElement> imps) { EList<PackageableElement> importMembers = new UniqueEList.FastCompare<PackageableElement>(); EList<NamedElement> ownedMembers = namespace.getOwnedMembers(); excludeCollisionsLoop : for (PackageableElement excludeCollision : namespace .excludeCollisions(imps)) { for (NamedElement ownedMember : ownedMembers) { if (!excludeCollision.isDistinguishableFrom(ownedMember, namespace)) { continue excludeCollisionsLoop; } } importMembers.add(excludeCollision); } return ECollections.unmodifiableEList(importMembers); }
protected Collection<EObject> getEObjects(AnyType extension, Resource resource, String name, boolean remove) { Collection<EObject> eObjects = new UniqueEList.FastCompare<EObject>(); if (extension != null) { Collection<Object> values = getValues(extension.getAnyAttribute(), name, remove); if (values.isEmpty()) { values = getValues(extension.getMixed(), name, remove); for (Object value : values) { if (value instanceof EObject) { eObjects.add((EObject) value); } } } else if (resource != null) { for (Object value : values) { if (value instanceof String) { EObject eObject = resource.getEObject((String) value); if (eObject != null) { eObjects.add(eObject); } } } } } return eObjects; }
private Collection<EObject> getEObjects(AnyType extension, Resource resource, String name, boolean remove) { Collection<EObject> eObjects = new UniqueEList.FastCompare<EObject>(); if (extension != null) { Collection<Object> values = getValues(extension.getAnyAttribute(), name, remove); if (values.isEmpty()) { values = getValues(extension.getMixed(), name, remove); for (Object value : values) { if (value instanceof EObject) { eObjects.add((EObject) value); } } } else if (resource != null) { for (Object value : values) { if (value instanceof String) { EObject eObject = resource.getEObject((String) value); if (eObject != null) { eObjects.add(eObject); } } } } } return eObjects; }
/** * Retrieves the named element(s) of the specified type with the specified * qualified name from the specified resource, optionally ignoring case when * doing name comparisons. * * @param resource * The resource in which to search. * @param qualifiedName * The qualified name of the element(s) to be found. * @param ignoreCase * Whether to ignore case when doing name comparisons. * @param eClass * The type of the element(s) to be found. * @return The named element(s). */ public static <NE extends NamedElement> Collection<NE> findNamedElements( Resource resource, String qualifiedName, boolean ignoreCase, EClass eClass) { if (!isEmpty(qualifiedName) && UMLPackage.Literals.NAMED_ELEMENT.isSuperTypeOf(eClass)) { EList<EObject> contents = resource.getContents(); if (!contents.isEmpty()) { EList<NE> namedElements = new UniqueEList.FastCompare<NE>(); findNamedElements(contents, qualifiedName, ignoreCase, eClass, namedElements); return ECollections.unmodifiableEList(namedElements); } } return ECollections.<NE> emptyEList(); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * <!-- begin-model-doc --> * Retrieves the associations in which this type is involved. * @param type The receiving '<em><b>Type</b></em>' model object. * <!-- end-model-doc --> * @generated NOT */ public static EList<Association> getAssociations(Type type) { EList<Association> associations = new UniqueEList.FastCompare<Association>(); for (EStructuralFeature.Setting nonNavigableInverseReference : getNonNavigableInverseReferences(type)) { if (nonNavigableInverseReference.getEStructuralFeature() == UMLPackage.Literals.TYPED_ELEMENT__TYPE) { EObject eObject = nonNavigableInverseReference.getEObject(); if (eObject instanceof Property) { Association association = ((Property) eObject) .getAssociation(); if (association != null) { associations.add(association); } } } } return ECollections.unmodifiableEList(associations); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * <!-- begin-model-doc --> * Retrieves the communication paths in which this node is involved. * @param node The receiving '<em><b>Node</b></em>' model object. * <!-- end-model-doc --> * @generated NOT */ public static EList<CommunicationPath> getCommunicationPaths(Node node) { EList<CommunicationPath> communicationPaths = new UniqueEList.FastCompare<CommunicationPath>(); for (EStructuralFeature.Setting nonNavigableInverseReference : getNonNavigableInverseReferences(node)) { if (nonNavigableInverseReference.getEStructuralFeature() == UMLPackage.Literals.TYPED_ELEMENT__TYPE) { EObject eObject = nonNavigableInverseReference.getEObject(); if (eObject instanceof Property) { Association association = ((Property) eObject) .getAssociation(); if (association instanceof CommunicationPath) { communicationPaths.add((CommunicationPath) association); } } } } return ECollections.unmodifiableEList(communicationPaths); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * <!-- begin-model-doc --> * The query excludeCollisions() excludes from a set of PackageableElements any that would not be distinguishable from each other in this namespace. * result = imps->reject(imp1 | imps.exists(imp2 | not imp1.isDistinguishableFrom(imp2, self))) * @param namespace The receiving '<em><b>Namespace</b></em>' model object. * <!-- end-model-doc --> * @generated NOT */ public static EList<PackageableElement> excludeCollisions( Namespace namespace, EList<PackageableElement> imps) { EList<PackageableElement> excludeCollisions = new UniqueEList.FastCompare<PackageableElement>(); imps1Loop : for (PackageableElement imp1 : imps) { for (PackageableElement imp2 : imps) { if (imp1 != imp2 && !imp1.isDistinguishableFrom(imp2, namespace)) { continue imps1Loop; } } excludeCollisions.add(imp1); } return ECollections.unmodifiableEList(excludeCollisions); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * <!-- begin-model-doc --> * The query getNamesOfMember() takes importing into account. It gives back the set of names that an element would have in an importing namespace, either because it is owned, or if not owned then imported individually, or if not individually then from a package. * The query getNamesOfMember() gives a set of all of the names that a member would have in a Namespace. In general a member can have multiple names in a Namespace if it is imported more than once with different aliases. The query takes account of importing. It gives back the set of names that an element would have in an importing namespace, either because it is owned, or if not owned then imported individually, or if not individually then from a package. * result = if self.ownedMember ->includes(element) * then Set{}->include(element.name) * else let elementImports: ElementImport = self.elementImport->select(ei | ei.importedElement = element) in * if elementImports->notEmpty() * then elementImports->collect(el | el.getName()) * else self.packageImport->select(pi | pi.importedPackage.visibleMembers()->includes(element))-> collect(pi | pi.importedPackage.getNamesOfMember(element)) * endif * endif * @param namespace The receiving '<em><b>Namespace</b></em>' model object. * <!-- end-model-doc --> * @generated NOT */ public static EList<String> getNamesOfMember(Namespace namespace, NamedElement element) { return ECollections.unmodifiableEList(getNamesOfMember(namespace, element, new UniqueEList.FastCompare<Namespace>(), new UniqueEList<String>())); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated NOT */ public static EList<Interface> getProvideds(Port port) { EList<Interface> provideds = new UniqueEList.FastCompare<Interface>(); Type type = (Type) port.eGet(UMLPackage.Literals.TYPED_ELEMENT__TYPE, false); if (type instanceof Interface) { provideds.add((Interface) type); } else if (type instanceof Classifier) { Classifier classifier = (Classifier) port.getType(); ComponentOperations.realizedInterfaces(null, classifier, false, provideds); for (Classifier parent : classifier.allParents()) { ComponentOperations.realizedInterfaces(null, parent, false, provideds); } } return new UnionEObjectEList<Interface>((InternalEObject) port, UMLPackage.Literals.PORT__PROVIDED, provideds.size(), provideds .toArray()); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * <!-- begin-model-doc --> * endType is derived from the types of the member ends. * result = self.memberEnd->collect(e | e.type) * @param association The receiving '<em><b>Association</b></em>' model object. * <!-- end-model-doc --> * @generated NOT */ public static EList<Type> getEndTypes(Association association) { EList<Type> endTypes = new UniqueEList.FastCompare<Type>(); for (Property memberEnd : association.getMemberEnds()) { Type endType = (Type) memberEnd.eGet( UMLPackage.Literals.TYPED_ELEMENT__TYPE, false); if (endType != null) { endTypes.add(endType); } } return new UnionEObjectEList<Type>((InternalEObject) association, UMLPackage.Literals.ASSOCIATION__END_TYPE, endTypes.size(), endTypes.toArray()); }
private Collection<EObject> getEObjects(AnyType extension, Resource resource, String name, boolean remove) { Collection<EObject> eObjects = new UniqueEList.FastCompare<EObject>(); if (extension != null) { Collection<Object> values = getValues(extension.getAnyAttribute(), name, remove); if (values.isEmpty()) { values = getValues(extension.getMixed(), name, remove); for (Object value : values) { if (value instanceof EObject) { eObjects.add((EObject) value); } } } else if (resource != null) { for (Object value : values) { if (value instanceof String) { EObject eObject = resource.getEObject((String) value); if (eObject != null) { eObjects.add(eObject); } } } } } return eObjects; }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * <!-- begin-model-doc --> * Retrieves the directed relationships of the specified type for which this element is a source. * @param element The receiving '<em><b>Element</b></em>' model object. * @param eClass The (meta)type of the directed relationships to retrieve. * <!-- end-model-doc --> * @generated NOT */ public static EList<DirectedRelationship> getSourceDirectedRelationships( Element element, EClass eClass) { EList<DirectedRelationship> sourceDirectedRelationships = new UniqueEList.FastCompare<DirectedRelationship>(); for (Iterator<Relationship> directedRelationships = getRelationships( element, eClass).iterator(); directedRelationships.hasNext();) { DirectedRelationship directedRelationship = (DirectedRelationship) directedRelationships .next(); if (directedRelationship.getSources().contains(element)) { sourceDirectedRelationships.add(directedRelationship); } } return ECollections.unmodifiableEList(sourceDirectedRelationships); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * <!-- begin-model-doc --> * Retrieves the metaclasses referenced by this profile. * @param profile The receiving '<em><b>Profile</b></em>' model object. * <!-- end-model-doc --> * @generated NOT */ public static EList<org.eclipse.uml2.uml.Class> getReferencedMetaclasses( Profile profile) { EList<org.eclipse.uml2.uml.Class> referencedMetaclasses = new UniqueEList.FastCompare<org.eclipse.uml2.uml.Class>(); for (ElementImport metaclassReference : profile .getMetaclassReferences()) { PackageableElement importedElement = metaclassReference .getImportedElement(); if (importedElement != null) { referencedMetaclasses .add((org.eclipse.uml2.uml.Class) importedElement); } } return ECollections.unmodifiableEList(referencedMetaclasses); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * <!-- begin-model-doc --> * Retrieves all the metaclasses extended by this stereotype, including the metaclasses extended by its superstereotypes. * @param stereotype The receiving '<em><b>Stereotype</b></em>' model object. * <!-- end-model-doc --> * @generated NOT */ public static EList<org.eclipse.uml2.uml.Class> getAllExtendedMetaclasses( Stereotype stereotype) { EList<org.eclipse.uml2.uml.Class> allExtendedMetaclasses = getExtendedMetaclasses( stereotype, new UniqueEList.FastCompare<org.eclipse.uml2.uml.Class>()); for (Classifier parent : stereotype.allParents()) { if (parent instanceof Stereotype) { getExtendedMetaclasses((Stereotype) parent, allExtendedMetaclasses); } } return ECollections.unmodifiableEList(allExtendedMetaclasses); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated NOT */ public static EList<Interface> getRequireds(Port port) { EList<Interface> requireds = new UniqueEList.FastCompare<Interface>(); Type type = (Type) port.eGet(UMLPackage.Literals.TYPED_ELEMENT__TYPE, false); if (type instanceof Classifier) { Classifier classifier = (Classifier) port.getType(); ComponentOperations.usedInterfaces(null, classifier, false, requireds); for (Classifier parent : classifier.allParents()) { ComponentOperations.usedInterfaces(null, parent, false, requireds); } } return new UnionEObjectEList<Interface>((InternalEObject) port, UMLPackage.Literals.PORT__REQUIRED, requireds.size(), requireds .toArray()); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * <!-- begin-model-doc --> * Retrieves the stereotype applications for this element. * @param element The receiving '<em><b>Element</b></em>' model object. * <!-- end-model-doc --> * @generated NOT */ public static EList<EObject> getStereotypeApplications(Element element) { EList<EObject> stereotypeApplications = new UniqueEList.FastCompare<EObject>(); for (EStructuralFeature.Setting setting : getNonNavigableInverseReferences(element)) { if (setting.getEStructuralFeature().getName().startsWith( Extension.METACLASS_ROLE_PREFIX)) { EObject eObject = setting.getEObject(); if (getStereotype(eObject) != null) { stereotypeApplications.add(eObject); } } } return ECollections.unmodifiableEList(stereotypeApplications); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * <!-- begin-model-doc --> * The query inheritableMembers() gives all of the members of a classifier that may be inherited in one of its descendants, subject to whatever visibility restrictions apply. * c.allParents()->includes(self) * result = member->select(m | c.hasVisibilityOf(m)) * @param classifier The receiving '<em><b>Classifier</b></em>' model object. * <!-- end-model-doc --> * @generated NOT */ public static EList<NamedElement> inheritableMembers(Classifier classifier, Classifier c) { EList<NamedElement> inheritableMembers = new UniqueEList.FastCompare<NamedElement>(); if (c == classifier || !c.allParents().contains(classifier) || classifier.allParents().contains(c)) { return inheritableMembers; } for (NamedElement member : classifier.getMembers()) { if (c.hasVisibilityOf(member)) { inheritableMembers.add(member); } } return ECollections.unmodifiableEList(inheritableMembers); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * <!-- begin-model-doc --> * Retrieves the elements imported by this namespace. * @param namespace The receiving '<em><b>Namespace</b></em>' model object. * <!-- end-model-doc --> * @generated NOT */ public static EList<PackageableElement> getImportedElements( Namespace namespace) { EList<PackageableElement> importedElements = new UniqueEList.FastCompare<PackageableElement>(); for (ElementImport elementImport : namespace.getElementImports()) { PackageableElement importedElement = elementImport .getImportedElement(); if (importedElement != null) { importedElements.add(importedElement); } } return ECollections.unmodifiableEList(importedElements); }