예제 #1
0
 private boolean isValidNamespace(MGeneralizableElement gen, MNamespace ns) {
   Iterator it = gen.getParents().iterator();
   while (it.hasNext()) {
     MGeneralizableElement gen2 = (MGeneralizableElement) it.next();
     if (!ns.getOwnedElements().contains(gen2)) {
       return false;
     }
   }
   return true;
 }
예제 #2
0
 /**
  * Gets the generalization between two generalizable elements. Returns null if there is none.
  *
  * @param child
  * @param parent
  * @return MGeneralization
  */
 public MGeneralization getGeneralization(
     MGeneralizableElement child, MGeneralizableElement parent) {
   if (child == null || parent == null) return null;
   Iterator it = child.getGeneralizations().iterator();
   while (it.hasNext()) {
     MGeneralization gen = (MGeneralization) it.next();
     if (gen.getParent() == parent) {
       return gen;
     }
   }
   return null;
 }
예제 #3
0
 /**
  * Returns all elements that extend some class clazz.
  *
  * @param clazz
  * @return Collection
  */
 public Collection getExtendingElements(MGeneralizableElement clazz) {
   if (clazz == null) return new ArrayList();
   Iterator it = clazz.getSpecializations().iterator();
   List list = new ArrayList();
   while (it.hasNext()) {
     MGeneralization gen = (MGeneralization) it.next();
     MGeneralizableElement client = gen.getChild();
     if (client != null) {
       list.add(client);
     }
   }
   return list;
 }
예제 #4
0
 /**
  * Returns all classes some generalizable element clazz extends.
  *
  * @param clazz
  * @return Collection
  */
 public Collection getExtendedClassifiers(MGeneralizableElement clazz) {
   if (clazz == null) return new ArrayList();
   Iterator it = clazz.getGeneralizations().iterator();
   List list = new ArrayList();
   while (it.hasNext()) {
     MGeneralization gen = (MGeneralization) it.next();
     MGeneralizableElement parent = gen.getParent();
     if (parent != null) {
       list.add(parent);
     }
   }
   return list;
 }