Skip to content

Commit

Permalink
Merge pull request AY2324S1-CS2103T-T12-4#37 from ryanongwx/branch-Se…
Browse files Browse the repository at this point in the history
…arch

Branch Search
  • Loading branch information
Darren159 authored Oct 16, 2023
2 parents b7d0a5d + ce734c2 commit 74ed8a5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ _Details coming soon ..._
| **Add** | `add n/NAME p/PHONE_NUMBER e/EMAIL a/ADDRESS [t/TAG]…​` <br> e.g., `add n/James Ho p/22224444 e/[email protected] a/123, Clementi Rd, 1234665 t/friend t/colleague`|
| **List** | `list`|
| **Edit** | `editdetail [patient ID/detail field/updated patient details]`<br> e.g.,`editdetail 1/email/[email protected]`|
| **Find** | `find KEYWORD [MORE_KEYWORDS]`<br> e.g., `find James Jake`|
| **search** | `search KEYWORDS]`<br> e.g., `find James Jake`|
| **Delete** | `delete [patientId]`<br> e.g., `delete 3`|
| **Pin** | `pin [patientId]`<br> e.g., `pin 2`|
| **Clear** | `clear`|
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/seedu/address/logic/commands/FindCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
import seedu.address.model.person.NameContainsKeywordsPredicate;

/**
* Finds and lists all persons in address book whose name contains any of the argument keywords.
* Finds and lists all persons in address book whose name contains any of the
* argument keywords.
* Keyword matching is case insensitive.
*/
public class FindCommand extends Command {

public static final String COMMAND_WORD = "find";
public static final String COMMAND_WORD = "search";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all persons whose names contain any of "
+ "the specified keywords (case-insensitive) and displays them as a list with index numbers.\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@ public NameContainsKeywordsPredicate(List<String> keywords) {
@Override
public boolean test(Person person) {
return keywords.stream()
.anyMatch(keyword -> StringUtil.containsWordIgnoreCase(person.getName().fullName, keyword));
.anyMatch(keyword -> StringUtil.containsWordIgnoreCase(person.getName().fullName, keyword) ||
StringUtil.containsWordIgnoreCase(person.getPhone().value, keyword) ||
person.getAllergies().stream()
.anyMatch(hobby -> StringUtil.containsWordIgnoreCase(hobby.allergy, keyword))
||
StringUtil.containsWordIgnoreCase(person.getGender().gender, keyword) ||
StringUtil.containsWordIgnoreCase(person.getBloodType().bloodType, keyword) ||
StringUtil.containsWordIgnoreCase(person.getAge().age.toString(), keyword) ||
StringUtil.containsWordIgnoreCase(person.getEmail().value, keyword));
}

@Override
Expand Down

0 comments on commit 74ed8a5

Please sign in to comment.