Ejemplo n.º 1
0
  @Override
  public int compareTo(User thatObj) {

    int cmp;

    cmp = this.getUsername().compareTo(thatObj.getUsername());
    if (cmp != 0) return cmp;

    return cmp;
  }
Ejemplo n.º 2
0
  @Override
  public boolean equals(Object that) {

    // Check references for equality
    if (this == that) return true;

    // Check for null
    if (that == null) return false;

    // Check candidate is an instance of Dbo.user
    if (!(that instanceof User)) return false;

    // Safely cast to Dbo.user
    User thatObj = (User) that;

    // Equality is based on natural id
    return this.getUsername() == null
        ? thatObj.getUsername() == null
        : this.getUsername().equals(thatObj.getUsername()) && true;
  }