/** * Collects all associations the classifier and their interfaces have. * * @param classifier * The classifier the associations should be collected * @return An <code>EList</code> with all collected associations */ @SuppressWarnings("unchecked") public EList<Association> getAllAssociations(Classifier classifier) { EList<Association> associations = new UniqueEList<Association>(); associations.addAll(classifier.getAssociations()); if (classifier instanceof org.eclipse.uml2.uml.Class) { Class clazz = (Class) classifier; for (int i = 0; i < clazz.getImplementedInterfaces().size(); i++) { associations.addAll(getAllInterfaceAssociations(clazz .getImplementedInterfaces().get(i))); } } return associations; }
/** * 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; }
/** * Collects all dependencies the NamedElement has. In the case of a Class * the dependencies of its interfaces will be processed too. * * @param element * The NamedElement the dependencies should be collected * @return An <code>EList</code> with all collected dependencies */ @SuppressWarnings("unchecked") public EList<Dependency> getAllDependencies(NamedElement element) { EList<Dependency> dependencies = new UniqueEList<Dependency>(); dependencies.addAll(element.getClientDependencies()); if (element instanceof org.eclipse.uml2.uml.Class) { Class clazz = (Class) element; for (int i = 0; i < clazz.getImplementedInterfaces().size(); i++) { dependencies.addAll(getAllInterfaceAssociations(clazz .getImplementedInterfaces().get(i))); } } EList<Dependency> depsFiltered = new UniqueEList<Dependency>(); for (Iterator<Dependency> iter = dependencies.iterator(); iter .hasNext();) { Dependency e = iter.next(); if (!(e instanceof InterfaceRealization)) { depsFiltered.add(e); } } return depsFiltered; }