Skip to content
This repository has been archived by the owner on Mar 5, 2023. It is now read-only.

Commit

Permalink
Model interface: Add method to get predicate of filteredPersonList
Browse files Browse the repository at this point in the history
The Model interface does not contain any method to
get the predicate of its filteredPersonList.

This prevents other classes from getting the predicate if
necessary.

Let's add a method in Model to get the predicate of its
filteredPersonList
  • Loading branch information
yamidark committed Jan 10, 2018
1 parent 1bee16f commit 1835928
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main/java/seedu/address/model/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ void updatePerson(ReadOnlyPerson target, ReadOnlyPerson editedPerson)
/** Returns an unmodifiable view of the filtered person list */
ObservableList<ReadOnlyPerson> getFilteredPersonList();

/** Returns the predicate used in the filtered person list */
Predicate<ReadOnlyPerson> getFilteredPersonListPredicate();

/**
* Updates the filter of the filtered person list to filter by the given {@code predicate}.
* @throws NullPointerException if {@code predicate} is null.
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/seedu/address/model/ModelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ public ObservableList<ReadOnlyPerson> getFilteredPersonList() {
return FXCollections.unmodifiableObservableList(filteredPersons);
}

@Override
public Predicate<ReadOnlyPerson> getFilteredPersonListPredicate() {
return (Predicate<ReadOnlyPerson>) filteredPersons.getPredicate();
}

@Override
public void updateFilteredPersonList(Predicate<ReadOnlyPerson> predicate) {
requireNonNull(predicate);
Expand Down
12 changes: 12 additions & 0 deletions src/test/java/seedu/address/logic/commands/AddCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ public ObservableList<ReadOnlyPerson> getFilteredPersonList() {
return null;
}

@Override
public Predicate<ReadOnlyPerson> getFilteredPersonListPredicate() {
fail("This method should not be called.");
return null;
}

@Override
public void updateFilteredPersonList(Predicate<ReadOnlyPerson> predicate) {
fail("This method should not be called.");
Expand All @@ -148,6 +154,9 @@ public void addPerson(ReadOnlyPerson person) throws DuplicatePersonException {
public ReadOnlyAddressBook getAddressBook() {
return new AddressBook();
}

@Override
public Predicate<ReadOnlyPerson> getFilteredPersonListPredicate() { return PREDICATE_SHOW_ALL_PERSONS; }
}

/**
Expand All @@ -165,6 +174,9 @@ public void addPerson(ReadOnlyPerson person) throws DuplicatePersonException {
public ReadOnlyAddressBook getAddressBook() {
return new AddressBook();
}

@Override
public Predicate<ReadOnlyPerson> getFilteredPersonListPredicate() { return PREDICATE_SHOW_ALL_PERSONS; }
}

}

0 comments on commit 1835928

Please sign in to comment.