/**
   * Compares all GraphElementClass objects in two Packages.
   *
   * @param xPackage Package from the Schema, of which all GraphElementClass objects should be
   *     compared.
   * @param gPackage Package from the SchemaGraph, of which all GraphElementClass objects should be
   *     compared.
   */
  private final void compareAllGraphElementClasses(
      de.uni_koblenz.jgralab.schema.Package xPackage, Package gPackage) {
    // Gets a cloned map of all VertexClass and EdgeClass objects
    Map<String, de.uni_koblenz.jgralab.schema.VertexClass> vertexClasses =
        new HashMap<String, de.uni_koblenz.jgralab.schema.VertexClass>(xPackage.getVertexClasses());
    Map<String, de.uni_koblenz.jgralab.schema.EdgeClass> edgeClasses =
        new HashMap<String, de.uni_koblenz.jgralab.schema.EdgeClass>(xPackage.getEdgeClasses());

    // This loop prevents the comparison of internal structures
    for (Iterator<Entry<String, de.uni_koblenz.jgralab.schema.VertexClass>> it =
            vertexClasses.entrySet().iterator();
        it.hasNext(); ) {
      if (it.next().getValue().isInternal()) {
        it.remove();
      }
    }

    // This loop prevents the comparison of internal structures
    for (Iterator<Entry<String, de.uni_koblenz.jgralab.schema.EdgeClass>> it =
            edgeClasses.entrySet().iterator();
        it.hasNext(); ) {
      if (it.next().getValue().isInternal()) {
        it.remove();
      }
    }

    // Loop over all ContainsGraphElementClass edges
    for (ContainsGraphElementClass containsGraphElementClass :
        gPackage.getContainsGraphElementClassIncidences(OUTGOING)) {

      // The referenced object should be at least a FraphElementClass
      assertTrue(
          "Omega should be an instance of GraphElementClass.",
          containsGraphElementClass.getOmega() instanceof GraphElementClass);

      Vertex omega = containsGraphElementClass.getOmega();
      assert omega != null;

      // Distinguishing between VertexClass and EdgeClass
      if (omega instanceof VertexClass) {
        VertexClass gVertexClass = (VertexClass) omega;
        // Retrieving the simple name of the corresponding VertexClass
        String simpleName =
            schema.getAttributedElementClass(gVertexClass.get_qualifiedName()).getSimpleName();
        // Queries, removes and compares at the same time two
        // VertexClass objects
        compareVertexClass(vertexClasses.remove(simpleName), gVertexClass);
      } else if (omega instanceof EdgeClass) {
        // The Same for the EdgeClass comparison
        EdgeClass gEdgeClass = (EdgeClass) omega;
        // Retrieving the simple name of the corresponding VertexClass
        String simpleName =
            schema.getAttributedElementClass(gEdgeClass.get_qualifiedName()).getSimpleName();
        // Queries, removes and compares at the same time two EdgeClass
        // objects
        compareEdgeClass(edgeClasses.remove(simpleName), gEdgeClass);
      } else {
        throw new RuntimeException("Unexpected type " + omega);
      }
    }

    // Both maps should be empty.

    assertTrue(
        "There are more VertexClasses in Schema then in the SchemaGraph.", vertexClasses.isEmpty());
    for (de.uni_koblenz.jgralab.schema.EdgeClass e : edgeClasses.values()) {
      System.out.println(e.getQualifiedName());
    }
    assertTrue(
        "There are more EdgeClasses in Schema then in the SchemaGraph.", edgeClasses.isEmpty());
  }