Skip to content

Commit

Permalink
Add equals() to FilterCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
iynixil committed Mar 13, 2024
1 parent 5736017 commit 435dcbd
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/main/java/staffconnect/logic/commands/FilterCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
// import static staffconnect.logic.parser.CliSyntax.PREFIX_FACULTY; // TODO: add filtering for faculty and module
// import static staffconnect.logic.parser.CliSyntax.PREFIX_MODULE;
import static staffconnect.logic.parser.CliSyntax.PREFIX_TAG;

import staffconnect.commons.util.ToStringBuilder;
import staffconnect.model.Model;
import staffconnect.model.person.PersonHasTagPredicate; // TagContainsKeywordsPredicate

Expand Down Expand Up @@ -44,4 +46,26 @@ public CommandResult execute(Model model) {
String.format(Messages.MESSAGE_PERSONS_LISTED_OVERVIEW, model.getFilteredPersonList().size()));
}

@Override
public boolean equals(Object other) {
if (other == this) {
return true;
}

// instanceof handles nulls
if (!(other instanceof FilterCommand)) {
return false;
}

FilterCommand otherFilterCommand = (FilterCommand) other;
return tagPredicate.equals(otherFilterCommand.tagPredicate);
}

@Override
public String toString() {
return new ToStringBuilder(this)
.add("tagPredicate", tagPredicate)
.toString();
}

}

0 comments on commit 435dcbd

Please sign in to comment.