From 435dcbdf69793d0e37130979347d10f39db5efcc Mon Sep 17 00:00:00 2001 From: iynixil Date: Wed, 13 Mar 2024 13:41:01 +0800 Subject: [PATCH] Add equals() to FilterCommand --- .../logic/commands/FilterCommand.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/main/java/staffconnect/logic/commands/FilterCommand.java b/src/main/java/staffconnect/logic/commands/FilterCommand.java index 5f47d1170d3..9faac02fe10 100644 --- a/src/main/java/staffconnect/logic/commands/FilterCommand.java +++ b/src/main/java/staffconnect/logic/commands/FilterCommand.java @@ -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 @@ -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(); + } + }