Exemplo n.º 1
0
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   final GCI other = (GCI) obj;
   if (!lhs.equals(other.lhs)) return false;
   if (!rhs.equals(other.rhs)) return false;
   return true;
 }
Exemplo n.º 2
0
  @Override
  public NormalFormGCI getNormalForm() {
    final NormalFormGCI result;
    // try {
    if (lhs instanceof Concept) {
      if (rhs instanceof Concept) {
        final int newLhs = lhs.hashCode();
        result = NF1a.getInstance(newLhs, rhs.hashCode());
      } else if (rhs instanceof Existential) {
        final Existential existential = (Existential) rhs;
        result =
            NF2.getInstance(
                lhs.hashCode(), existential.getRole(), existential.getConcept().hashCode());
      } else if (rhs instanceof Datatype) {
        final Datatype datatype = (Datatype) rhs;
        result = NF7.getInstance(lhs.hashCode(), datatype);
      } else {
        throw new IllegalStateException(
            "GCI is not in Normal Form: "
                + "lhs is Concept but rhs is neither Concept, "
                + "Existential nor Datatype; it is "
                + rhs);
      }
    } else if (lhs instanceof Conjunction) {
      final Conjunction conjunction = (Conjunction) lhs;
      final AbstractConcept[] concepts = conjunction.getConcepts();
      if (concepts.length == 1) {
        result = NF1a.getInstance(concepts[0].hashCode(), rhs.hashCode());
      } else if (concepts.length == 2) {
        result = NF1b.getInstance(concepts[0].hashCode(), concepts[1].hashCode(), rhs.hashCode());
      } else {
        throw new IllegalStateException(
            "Conjunction should have exactly one or two "
                + "Concepts not "
                + concepts.length
                + ": "
                + conjunction);
      }
    } else if (lhs instanceof Existential) {
      Existential existential = (Existential) lhs;
      result =
          NF3.getInstance(
              existential.getRole(), existential.getConcept().hashCode(), rhs.hashCode());
    } else if (lhs instanceof Datatype) {
      Datatype datatype = (Datatype) lhs;
      result = NF8.getInstance(datatype, rhs.hashCode());
    } else {
      throw new IllegalStateException("GCI is not in Normal Form: " + lhs + ", " + rhs);
    }

    return result;
  }
Exemplo n.º 3
0
 @Override
 public String toString() {
   return lhs.toString() + " [ " + rhs.toString();
 }