Skip to content

Commit

Permalink
Allow multiple wedding and tag search
Browse files Browse the repository at this point in the history
  • Loading branch information
tingxuanp committed Oct 29, 2024
1 parent 62ba228 commit 4b1693f
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/main/java/seedu/address/logic/parser/FindCommandParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> 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<String> 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<String> 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<String> weddingKeywords = Arrays.asList(weddingInput.split("\\s+"));
return new FindWeddingCommand(new WeddingContainsKeywordsPredicate(weddingKeywords));
}

Expand Down

0 comments on commit 4b1693f

Please sign in to comment.