示例#1
0
  @Override
  public int compareTo(Activity thatObj) {

    int cmp;

    cmp =
        this.getDescription() == null
            ? (thatObj.getDescription() == null ? 0 : -1)
            : (thatObj.getDescription() == null
                ? 1
                : this.getDescription().compareTo(thatObj.getDescription()));
    if (cmp != 0) return cmp;
    cmp =
        this.getHours() == null
            ? (thatObj.getHours() == null ? 0 : -1)
            : (thatObj.getHours() == null ? 1 : this.getHours().compareTo(thatObj.getHours()));
    if (cmp != 0) return cmp;
    cmp =
        this.getTimesheet() == null
            ? (thatObj.getTimesheet() == null ? 0 : -1)
            : (thatObj.getTimesheet() == null
                ? 1
                : this.getTimesheet().compareTo(thatObj.getTimesheet()));
    if (cmp != 0) return cmp;

    return cmp;
  }
示例#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 Test.activity
    if (!(that instanceof Activity)) return false;

    // Safely cast to Test.activity
    Activity thatObj = (Activity) that;

    // Equality is based on all field values
    return this.getDescription() == null
        ? thatObj.getDescription() == null
        : this.getDescription().equals(thatObj.getDescription()) && this.getHours() == null
            ? thatObj.getHours() == null
            : this.getHours().equals(thatObj.getHours()) && this.getTimesheet() == null
                ? thatObj.getTimesheet() == null
                : this.getTimesheet().equals(thatObj.getTimesheet()) && true;
  }