From 4b1693f986afe920e640814c51ca84452f3fc1d6 Mon Sep 17 00:00:00 2001 From: tingxuanp Date: Tue, 29 Oct 2024 09:47:33 +0800 Subject: [PATCH] Allow multiple wedding and tag search --- .../logic/parser/FindCommandParser.java | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/main/java/seedu/address/logic/parser/FindCommandParser.java b/src/main/java/seedu/address/logic/parser/FindCommandParser.java index 639620b5b1d..138ebfb847f 100644 --- a/src/main/java/seedu/address/logic/parser/FindCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/FindCommandParser.java @@ -116,20 +116,28 @@ public FindCommand parse(String args) throws ParseException { } if (hasTagPrefix) { - String tagInput = argMultimap.getValue(PREFIX_TAG).get().trim(); - if (tagInput.isEmpty()) { - throw new ParseException(TAG_CANNOT_BE_EMPTY); + List tagKeywords = new ArrayList<>(); + for (String tag : argMultimap.getAllValues(PREFIX_TAG)) { + String tagInput = tag.trim(); + if (tagInput.isEmpty()) { + throw new ParseException(TAG_CANNOT_BE_EMPTY); + } + tagKeywords.add(tagInput); } - List tagKeywords = Arrays.asList(tagInput.split("\\s+")); + + return new FindTagCommand(new TagContainsKeywordsPredicate(tagKeywords)); } if (hasWeddingPrefix) { - String weddingInput = argMultimap.getValue(PREFIX_WEDDING).get().trim(); - if (weddingInput.isEmpty()) { - throw new ParseException(WEDDING_CANNOT_BE_EMPTY); + List weddingKeywords = new ArrayList<>(); + for (String wedding : argMultimap.getAllValues(PREFIX_WEDDING)) { + String weddingInput = wedding.trim(); + if (weddingInput.isEmpty()) { + throw new ParseException(WEDDING_CANNOT_BE_EMPTY); + } + weddingKeywords.add(weddingInput); } - List weddingKeywords = Arrays.asList(weddingInput.split("\\s+")); return new FindWeddingCommand(new WeddingContainsKeywordsPredicate(weddingKeywords)); }