|
| 1 | +package seedu.address.logic.commands.reminder; |
| 2 | + |
| 3 | +import static java.util.Objects.requireNonNull; |
| 4 | + |
| 5 | +import seedu.address.commons.core.Messages; |
| 6 | +import seedu.address.logic.commands.Command; |
| 7 | +import seedu.address.logic.commands.CommandResult; |
| 8 | +import seedu.address.model.Model; |
| 9 | +import seedu.address.model.reminder.ReminderNameContainsKeywordsPredicate; |
| 10 | + |
| 11 | +/** |
| 12 | + * Finds and lists all persons in address book whose name contains any of the argument keywords. |
| 13 | + * Keyword matching is case insensitive. |
| 14 | + */ |
| 15 | +public class ReminderFindCommand extends Command { |
| 16 | + |
| 17 | + public static final String COMMAND_WORD = "findr"; |
| 18 | + |
| 19 | + public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all reminders whose titles contain any of " |
| 20 | + + "the specified keywords (case-insensitive) and displays them as a list with index numbers.\n" |
| 21 | + + "Parameters: KEYWORD [MORE_KEYWORDS]...\n" |
| 22 | + + "Example: " + COMMAND_WORD + " meeting"; |
| 23 | + |
| 24 | + private final ReminderNameContainsKeywordsPredicate predicate; |
| 25 | + |
| 26 | + public ReminderFindCommand(ReminderNameContainsKeywordsPredicate predicate) { |
| 27 | + this.predicate = predicate; |
| 28 | + } |
| 29 | + |
| 30 | + @Override |
| 31 | + public CommandResult execute(Model model) { |
| 32 | + requireNonNull(model); |
| 33 | + model.updateFilteredReminderList(predicate); |
| 34 | + return new CommandResult( |
| 35 | + String.format(Messages.MESSAGE_REMINDERS_LISTED_OVERVIEW, model.getFilteredReminderList().size())); |
| 36 | + } |
| 37 | + |
| 38 | + @Override |
| 39 | + public boolean equals(Object other) { |
| 40 | + return other == this // short circuit if same object |
| 41 | + || (other instanceof ReminderFindCommand // instanceof handles nulls |
| 42 | + && predicate.equals(((ReminderFindCommand) other).predicate)); // state check |
| 43 | + } |
| 44 | +} |
0 commit comments