예제 #1
0
  /**
   * Updates the stored user with any not null information in the passed user
   *
   * @param u The user to update from.
   * @throws InvalidFieldException Thrown if anything is of the wrong format.
   */
  public void update(User u) throws InvalidFieldException {
    if (u.getFirstName() != null) {
      setFirstName(u.getFirstName());
    }

    if (u.getLastName() != null) {
      setLastName(u.getLastName());
    }

    if (u.getID() != null) {
      setID(u.getID());
    }

    if (u.getPoints() != getPoints()) {
      setPoints(u.getPoints());
    }

    if (u.getWeeklyPick() != null && !u.getWeeklyPick().isNull()) {
      setWeeklyPick(u.getWeeklyPick());
    }

    if (u.getUltimatePick() != null && !u.getUltimatePick().isNull()) {
      setUltimatePickNoSetPts(u.getUltimatePick());
    }

    if (u.getUltimatePoints() != getUltimatePoints()) {
      setUltimatePoints(u.getUltimatePoints());
    }
  }
예제 #2
0
  /**
   * Compares two User objects.
   *
   * @return 0 Users are equal.
   * @return -1 User A is greater than User B.
   * @return 1 User B is greater than User A.
   */
  public int compareTo(User otherU) {
    // ugly, but works. :)
    int result = getID().compareToIgnoreCase(otherU.getID());
    if (result == 0) {
      result = getPoints() - otherU.getPoints();
      if (result == 0) {
        result = getLastName().compareToIgnoreCase(otherU.getLastName());
        if (result == 0) {
          result = getFirstName().compareToIgnoreCase(otherU.getLastName());
        }
      }
    }

    return result;
  }