Пример #1
0
  /**
   * Orders the child associations by ID. A smaller ID has a higher priority. This may change once
   * we introduce a changeable index against which to order.
   */
  public int compareTo(ChildAssoc another) {
    if (this == another) {
      return 0;
    }

    int thisIndex = this.getIndex();
    int anotherIndex = another.getIndex();

    Long thisId = this.getId();
    Long anotherId = another.getId();

    if (thisId == null) // this ID has not been set, make this instance greater
    {
      return -1;
    } else if (anotherId == null) // other ID has not been set, make this instance lesser
    {
      return 1;
    } else if (thisIndex == anotherIndex) // use the explicit index
    {
      return thisId.compareTo(anotherId);
    } else // fallback on order of creation
    {
      return (thisIndex > anotherIndex) ? 1 : -1; // a lower index, make this instance lesser
    }
  }
Пример #2
0
 public boolean equals(Object obj) {
   if (obj == null) {
     return false;
   } else if (obj == this) {
     return true;
   } else if (!(obj instanceof ChildAssoc)) {
     return false;
   }
   ChildAssoc that = (ChildAssoc) obj;
   if (EqualsHelper.nullSafeEquals(id, that.getId())) {
     return true;
   } else {
     return (EqualsHelper.nullSafeEquals(this.getParent(), that.getParent())
         && EqualsHelper.nullSafeEquals(this.typeQNameId, that.getTypeQNameId())
         && EqualsHelper.nullSafeEquals(this.getChild(), that.getChild())
         && EqualsHelper.nullSafeEquals(this.qnameLocalName, that.getQnameLocalName())
         && EqualsHelper.nullSafeEquals(this.qnameNamespaceId, that.getQnameNamespaceId()));
   }
 }