Skip to content

Commit

Permalink
simplify RecurringExpenseManager equals
Browse files Browse the repository at this point in the history
  • Loading branch information
shirsho-12 committed Apr 4, 2023
1 parent efa9875 commit 5e61574
Showing 1 changed file with 10 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,40 +184,16 @@ public String toString() {
}

@Override
public boolean equals(Object object) {
if (this == object) {
return true;
public boolean equals(Object obj) {
if (obj instanceof RecurringExpenseManager) {
RecurringExpenseManager other = (RecurringExpenseManager) obj;
return this.expenseName.equals(other.expenseName)
&& this.amount.equals(other.amount)
&& this.expenseCategory.equals(other.expenseCategory)
&& this.startDate.equals(other.startDate)
&& this.endDate == null ? other.endDate == null : this.endDate.equals(other.endDate)
&& this.recurringExpenseType.equals(other.recurringExpenseType);
}
if (object == null || getClass() != object.getClass()) {
return false;
}

RecurringExpenseManager recurringExpense = (RecurringExpenseManager) object;

if (!recurringExpense.startDate.isEqual(this.startDate)) {
return false;
}
if (recurringExpense.amount != this.amount) {
return false;
}
if (!recurringExpense.nextExpenseDate.isEqual(this.nextExpenseDate)) {
return false;
}
if (recurringExpense.recurringExpenseType != this.recurringExpenseType) {
return false;
}
if (!recurringExpense.expenseCategory.equals(this.expenseCategory)) {
return false;
}
if (!recurringExpense.expenseName.equals(this.expenseName)) {
return false;
}
if (recurringExpense.endDate == null) {
return this.endDate == null;
}
if (!recurringExpense.endDate.isEqual(this.endDate)) {
return false;
}
return true;
return false;
}
}

0 comments on commit 5e61574

Please sign in to comment.