Ejemplo n.º 1
0
  /**
   * Compare two Names for equality.
   *
   * @param other - the Name to compare to.
   * @return true if the components of these Names are equal.
   */
  private boolean isEqualTo(Name other) {
    //  Checking kind has already been done (via the hashCode())
    //  when called from equals().
    boolean result = true; /* this.kind == other.kind; */

    if (result && kind != CONSTANT_TypeName) {
      //  Check qualifiers, then base.
      if (this.qualifiers == other.qualifiers) {
        // result = true;
      } else if (this.qualifiers != null && other.qualifiers != null) {
        result = this.qualifiers.equals(other.qualifiers);
      } else {
        //  One qualifier is null, but not both
        result = false;
      }

      if (result) {
        String this_base = this.getBaseName();
        String other_base = other.getBaseName();

        if (this_base != null && other_base != null) {
          result = this_base.equals(other_base);
        } else {
          result = this_base == null && other_base == null;
        }
      }
    } else if (result) {
      // When comparing C1.<T1> to C2.<T2>,
      // first compare C1 to C2; if they're equal, compare T1 to T2.

      result = this.typeNameBase.equals(other.typeNameBase);

      if (result && this.typeNameParameter != null) {
        if (other.typeNameParameter != null)
          result = this.typeNameParameter.equals(other.typeNameParameter);
        else result = false;
      }
    }

    return result;
  }