private static Collection<Operation> resolveInterfaceOperationsRecursively(final Interface classifier) { // preserve ordering final Collection<Operation> operations = new LinkedHashSet<Operation>(classifier.getOwnedOperations()); final List<Classifier> generals = classifier.getGenerals(); for (final Classifier generalObject : generals) { if (generalObject instanceof Interface) { operations.addAll(resolveInterfaceOperationsRecursively((Interface) generalObject)); } } return operations; }
/** * Collects all attributes of the given interface needed to implement * (creating fields and getter/setter methods) by a implementing class. * * @param iFace * The interface to collect the operations from * @return An <code>EList</code> with all collected attributes */ private EList<Property> getAllInterfaceAttributes(Interface iFace) { EList<Property> attributes = new UniqueEList<Property>(); attributes.addAll(iFace.getAllAttributes()); if (iFace.getGeneralizations().size() > 0) { for (int i = 0; i < iFace.getGeneralizations().size(); i++) { attributes.addAll(getAllInterfaceAttributes((Interface) iFace .getGeneralizations().get(i).getGeneral())); } } return attributes; }
/** * Collects all associations of the given interface needed to implement by a * implementing class. * * @param iFace * The interface to collect the associations from * @return An <code>EList</code> with all collected associations */ @SuppressWarnings({ "rawtypes", "unchecked" }) private EList getAllInterfaceAssociations(Interface iFace) { EList associations = new UniqueEList(); associations.addAll(iFace.getAssociations()); if (iFace.getGeneralizations().size() > 0) { for (int i = 0; i < iFace.getGeneralizations().size(); i++) { associations .addAll(getAllInterfaceAssociations((Interface) iFace .getGeneralizations().get(i).getGeneral())); } } return associations; }
@Override public EList<Operation> caseInterface(Interface interface_) { return interface_.getOwnedOperations(); }
public void visitBefore(org.eclipse.uml2.uml.Interface inf) { OJAnnotatedInterface annotatedInterface = new OJAnnotatedInterface(Namer.name(inf)); OJPackage ojPackage = new OJPackage(Namer.name(inf.getNearestPackage())); annotatedInterface.setMyPackage(ojPackage); if (UmlgInterfaceOperations.hasCompositeOwner(inf)) { extendCompositionNode(annotatedInterface); } else { extendTumlNode(annotatedInterface); } for (Classifier c : inf.getGenerals()) { annotatedInterface.addToSuperInterfaces(UmlgClassOperations.getPathName(c)); } addAllInstances(inf, annotatedInterface); addAllInstancesWithFilter(inf, annotatedInterface); addToSource(annotatedInterface); }
@Override public Object caseInterface(Interface interface_) { if (!isEGenericType(interface_) && !interface_.isTemplateParameter()) { org.eclipse.uml2.uml.Package package_ = interface_ .getNearestPackage(); if (package_ != null) { EClass eClass = EcoreFactory.eINSTANCE.createEClass(); elementToEModelElementMap.put(interface_, eClass); EPackage ePackage = (EPackage) doSwitch(package_); ePackage.getEClassifiers().add(eClass); setName(eClass, interface_); eClass.setAbstract(true); eClass.setInterface(true); defaultCase(interface_); return eClass; } } return super.caseInterface(interface_); }
@Override public void visitBefore(Interface clazz) { OJAnnotatedClass metaClass = new OJAnnotatedClass(UmlgClassOperations.getMetaClassName(clazz)); OJPackage ojPackage = new OJPackage(Namer.name(clazz.getNearestPackage()) + ".meta"); metaClass.setMyPackage(ojPackage); metaClass.setVisibility(UmlgClassOperations.getVisibility(clazz.getVisibility())); if (ModelLoader.INSTANCE.isUmlGLibIncluded()) { metaClass.setSuperclass(UmlgGenerationUtil.BASE_CLASS_UMLG); addDefaultConstructor(metaClass, clazz); addContructorWithVertex(metaClass, clazz); //Ensure the meta class instance does not also try to create a edge to a meta class as it is also a normal entity addAddToThreadEntityVar(metaClass); } else { metaClass.setSuperclass(UmlgGenerationUtil.BASE_META_NODE); addDefaultConstructorStandAlone(metaClass, clazz); addConstructorWithVertexStandAlone(metaClass, clazz); } addToSource(metaClass); addGetEdgeToRootLabel(metaClass, clazz); addImplementsTumlMetaNode(metaClass); addMetaClassGetterToRoot(clazz, metaClass); addDefaultCreate(metaClass); // addGetAllInstancesForAbstractClass(clazz, metaClass); // addGetAllInstancesWithFilterForAbstractClass(clazz, metaClass); }
public static Set<Association> getAllAssociations(Classifier classifier) { Set<Association> result = new HashSet<Association>(); if (classifier instanceof Class) { for (Interface implementedInterface : ((Class) classifier).getAllImplementedInterfaces()) { result.addAll(filterOutRefinedAssociation(implementedInterface.getAssociations())); } } getAllAssociationsFromGenerals(classifier, result); return result; }
public static Set<Property> getAllProperties(Interface inf) { Set<Property> result = new HashSet<Property>(); result.addAll(inf.getAllAttributes()); Set<Association> associations = getAllAssociations(inf); for (Association association : associations) { List<Property> memberEnds = association.getMemberEnds(); for (Property property : memberEnds) { if (!UmlgClassOperations.isSpecializationOf(inf, property.getType())) { result.add(property); } } } return result; }
protected static EList<Interface> getAllRealizedInterfaces( BehavioredClassifier behavioredClassifier, EList<Interface> allRealizedInterfaces) { getRealizedInterfaces(behavioredClassifier, allRealizedInterfaces); for (Classifier parent : behavioredClassifier.allParents()) { if (parent instanceof BehavioredClassifier) { getRealizedInterfaces((BehavioredClassifier) parent, allRealizedInterfaces); } } for (int i = 0, size = allRealizedInterfaces.size(); i < size; i++) { for (Classifier parent : allRealizedInterfaces.get(i).allParents()) { if (parent instanceof Interface) { allRealizedInterfaces.add((Interface) parent); } } } return allRealizedInterfaces; }
@Override public Operation caseInterface(Interface interface_) { return interface_.createOwnedOperation(name, parameterNames, parameterTypes); } }.doSwitch(type);
@Override public Property caseInterface(Interface interface_) { return interface_.createOwnedAttribute(name, propertyType); }
public int getRelationship(Classifier type1, Classifier type2) { if (ObjectUtil.equal(type1, type2)) { return SAME_TYPE; } if (type2.conformsTo(type1)) { return STRICT_SUPERTYPE; } else if (type1.conformsTo(type2)) { return STRICT_SUBTYPE; } else if ((type2 instanceof BehavioredClassifier) && (type1 instanceof Interface)) { for (Interface i : ((BehavioredClassifier) type2).getAllImplementedInterfaces()) { if (i.conformsTo(type1)) { return STRICT_SUPERTYPE; } } } else if ((type1 instanceof BehavioredClassifier) && (type2 instanceof Interface)) { for (Interface i : ((BehavioredClassifier) type1).getAllImplementedInterfaces()) { if (i.conformsTo(type2)) { return STRICT_SUBTYPE; } } } return UNRELATED_TYPE; }
/** * @see org.andromda.metafacades.emf.uml22.ClassifierFacadeLogic#handleGetOperations() */ @Override protected List<Operation> handleGetOperations() { final List<Operation> operations; if (this.metaObject instanceof Class) { operations = ((Class)this.metaObject).getOwnedOperations(); } else if (this.metaObject instanceof Interface) { operations = ((Interface)this.metaObject).getOwnedOperations(); } else { operations = Collections.emptyList(); } //Collections.sort(operations, new OperationComparator()); return operations; }
for (Classifier parent : providedInterfaces.get(i).allParents()) {
private static Collection<Operation> resolveInterfaceOperationsRecursively(final Interface classifier) { // preserve ordering final Collection<Operation> operations = new LinkedHashSet<Operation>(classifier.getOwnedOperations()); final List<Classifier> generals = classifier.getGenerals(); for (final Classifier generalObject : generals) { if (generalObject instanceof Interface) { operations.addAll(resolveInterfaceOperationsRecursively((Interface) generalObject)); } } return operations; }
/** * @see org.andromda.metafacades.emf.uml22.ClassifierFacadeLogic#handleGetOperations() */ @Override protected List<Operation> handleGetOperations() { final List<Operation> operations; if (this.metaObject instanceof Class) { operations = ((Class)this.metaObject).getOwnedOperations(); } else if (this.metaObject instanceof Interface) { operations = ((Interface)this.metaObject).getOwnedOperations(); } else { operations = Collections.emptyList(); } //Collections.sort(operations, new OperationComparator()); return operations; }
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); }
operations = new LinkedHashSet<Operation>(((Interface)this.metaObject).getOwnedOperations());
operations = new LinkedHashSet<Operation>(((Interface)this.metaObject).getOwnedOperations());