diff --git a/docs/DeveloperGuide.adoc b/docs/DeveloperGuide.adoc index 05891ecb25f5..9838c0708364 100644 --- a/docs/DeveloperGuide.adoc +++ b/docs/DeveloperGuide.adoc @@ -205,7 +205,7 @@ The `Model`, * stores a `UserPref` object that represents the user's preferences. * stores the Address Book data. -* exposes an unmodifiable `ObservableList` that can be 'observed' e.g. the UI can be bound to this list so that the UI automatically updates when the data in the list change. +* exposes an unmodifiable `ObservableList` that can be 'observed' e.g. the UI can be bound to this list so that the UI automatically updates when the data in the list change. * does not depend on any of the other three components. [[Design-Storage]] @@ -561,7 +561,7 @@ image::getting-started-ui-tag-after.png[width="300"] + **** * Hints -** The tag labels are created inside link:{repoURL}/src/main/java/seedu/address/ui/PersonCard.java[`PersonCard#initTags(ReadOnlyPerson)`] (`new Label(tag.tagName)`). https://docs.oracle.com/javase/8/javafx/api/javafx/scene/control/Label.html[JavaFX's `Label` class] allows you to modify the style of each Label, such as changing its color. +** The tag labels are created inside link:{repoURL}/src/main/java/seedu/address/ui/PersonCard.java[`PersonCard#initTags(Person)`] (`new Label(tag.tagName)`). https://docs.oracle.com/javase/8/javafx/api/javafx/scene/control/Label.html[JavaFX's `Label` class] allows you to modify the style of each Label, such as changing its color. ** Use the .css attribute `-fx-background-color` to add a color. * Solution ** See this https://github.com/se-edu/addressbook-level4/pull/592/files[PR] for the full solution. @@ -683,7 +683,7 @@ Let's add a placeholder on all our link:{repoURL}/src/main/java/seedu/address/ui . Modify link:{repoURL}/src/test/java/guitests/guihandles/PersonCardHandle.java[`PersonCardHandle`] so that future tests can read the contents of the remark label. ===== [Step 4] Model: Add `Remark` class -We have to properly encapsulate the remark in our link:{repoURL}/src/main/java/seedu/address/model/person/ReadOnlyPerson.java[`ReadOnlyPerson`] class. Instead of just using a `String`, let's follow the conventional class structure that the codebase already uses by adding a `Remark` class. +We have to properly encapsulate the remark in our link:{repoURL}/src/main/java/seedu/address/model/person/Person.java[`Person`] class. Instead of just using a `String`, let's follow the conventional class structure that the codebase already uses by adding a `Remark` class. **Main:** @@ -694,12 +694,12 @@ We have to properly encapsulate the remark in our link:{repoURL}/src/main/java/s . Add test for `Remark`, to test the `Remark#equals()` method. -===== [Step 5] Model: Modify `ReadOnlyPerson` to support a `Remark` field -Now we have the `Remark` class, we need to actually use it inside link:{repoURL}/src/main/java/seedu/address/model/person/ReadOnlyPerson.java[`ReadOnlyPerson`]. +===== [Step 5] Model: Modify `Person` to support a `Remark` field +Now we have the `Remark` class, we need to actually use it inside link:{repoURL}/src/main/java/seedu/address/model/person/Person.java[`Person`]. **Main:** -. Add three methods `setRemark(Remark)`, `getRemark()` and `remarkProperty()`. Be sure to implement these newly created methods in link:{repoURL}/src/main/java/seedu/address/model/person/ReadOnlyPerson.java[`Person`], which implements the link:{repoURL}/src/main/java/seedu/address/model/person/ReadOnlyPerson.java[`ReadOnlyPerson`] interface. +. Add three methods `setRemark(Remark)`, `getRemark()` and `remarkProperty()`. Be sure to implement these newly created methods in link:{repoURL}/src/main/java/seedu/address/model/person/Person.java[`Person`], which implements the link:{repoURL}/src/main/java/seedu/address/model/person/Person.java[`Person`] interface. . You may assume that the user will not be able to use the `add` and `edit` commands to modify the remarks field (i.e. the person will be created without a remark). . Modify link:{repoURL}/src/main/java/seedu/address/model/util/SampleDataUtil.java/[`SampleDataUtil`] to add remarks for the sample data (delete your `addressBook.xml` so that the application will load the sample data when you launch it.) @@ -709,7 +709,7 @@ We now have `Remark` s for `Person` s, but they will be gone when we exit the ap **Main:** . Add a new Xml field for `Remark`. -. Be sure to modify the logic of the constructor and `toModelType()`, which handles the conversion to/from link:{repoURL}/src/main/java/seedu/address/model/person/ReadOnlyPerson.java[`ReadOnlyPerson`]. +. Be sure to modify the logic of the constructor and `toModelType()`, which handles the conversion to/from link:{repoURL}/src/main/java/seedu/address/model/person/Person.java[`Person`]. **Tests:** @@ -725,7 +725,7 @@ Our remark label in link:{repoURL}/src/main/java/seedu/address/ui/PersonCard.jav **Tests:** . Modify link:{repoURL}/src/test/java/seedu/address/ui/testutil/GuiTestAssert.java[`GuiTestAssert#assertCardDisplaysPerson(...)`] so that it will compare the remark label. -. In link:{repoURL}/src/test/java/seedu/address/ui/PersonCardTest.java[`PersonCardTest`], call `personWithTags.setRemark(ALICE.getRemark())` to test that changes in the link:{repoURL}/src/main/java/seedu/address/model/person/ReadOnlyPerson.java[`Person`] 's remark correctly updates the corresponding link:{repoURL}/src/main/java/seedu/address/ui/PersonCard.java[`PersonCard`]. +. In link:{repoURL}/src/test/java/seedu/address/ui/PersonCardTest.java[`PersonCardTest`], call `personWithTags.setRemark(ALICE.getRemark())` to test that changes in the link:{repoURL}/src/main/java/seedu/address/model/person/Person.java[`Person`] 's remark correctly updates the corresponding link:{repoURL}/src/main/java/seedu/address/ui/PersonCard.java[`PersonCard`]. ===== [Step 8] Logic: Implement `RemarkCommand#execute()` logic We now have everything set up... but we still can't modify the remarks. Let's finish it up by adding in actual logic for our `remark` command. diff --git a/docs/diagrams/ModelComponentClassDiagram.pptx b/docs/diagrams/ModelComponentClassDiagram.pptx index 5e7392e86ec6..418360e10b26 100644 Binary files a/docs/diagrams/ModelComponentClassDiagram.pptx and b/docs/diagrams/ModelComponentClassDiagram.pptx differ diff --git a/docs/images/ModelClassDiagram.png b/docs/images/ModelClassDiagram.png index 23d5c799beaa..7ea5b4b42fb2 100644 Binary files a/docs/images/ModelClassDiagram.png and b/docs/images/ModelClassDiagram.png differ diff --git a/src/main/java/seedu/address/logic/Logic.java b/src/main/java/seedu/address/logic/Logic.java index f6000c79262c..8b34b862039a 100644 --- a/src/main/java/seedu/address/logic/Logic.java +++ b/src/main/java/seedu/address/logic/Logic.java @@ -4,7 +4,7 @@ import seedu.address.logic.commands.CommandResult; import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.logic.parser.exceptions.ParseException; -import seedu.address.model.person.ReadOnlyPerson; +import seedu.address.model.person.Person; /** * API of the Logic component @@ -20,7 +20,7 @@ public interface Logic { CommandResult execute(String commandText) throws CommandException, ParseException; /** Returns an unmodifiable view of the filtered list of persons */ - ObservableList getFilteredPersonList(); + ObservableList getFilteredPersonList(); /** Returns the list of input entered by the user, encapsulated in a {@code ListElementPointer} object */ ListElementPointer getHistorySnapshot(); diff --git a/src/main/java/seedu/address/logic/LogicManager.java b/src/main/java/seedu/address/logic/LogicManager.java index f60c7aeebda8..71211f2a3ec1 100644 --- a/src/main/java/seedu/address/logic/LogicManager.java +++ b/src/main/java/seedu/address/logic/LogicManager.java @@ -11,7 +11,7 @@ import seedu.address.logic.parser.AddressBookParser; import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.Model; -import seedu.address.model.person.ReadOnlyPerson; +import seedu.address.model.person.Person; /** * The main LogicManager of the app. @@ -46,7 +46,7 @@ public CommandResult execute(String commandText) throws CommandException, ParseE } @Override - public ObservableList getFilteredPersonList() { + public ObservableList getFilteredPersonList() { return model.getFilteredPersonList(); } diff --git a/src/main/java/seedu/address/logic/commands/AddCommand.java b/src/main/java/seedu/address/logic/commands/AddCommand.java index 27b4f3578d78..2965e17c2b92 100644 --- a/src/main/java/seedu/address/logic/commands/AddCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddCommand.java @@ -9,7 +9,6 @@ import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.person.Person; -import seedu.address.model.person.ReadOnlyPerson; import seedu.address.model.person.exceptions.DuplicatePersonException; /** @@ -40,9 +39,9 @@ public class AddCommand extends UndoableCommand { private final Person toAdd; /** - * Creates an AddCommand to add the specified {@code ReadOnlyPerson} + * Creates an AddCommand to add the specified {@code Person} */ - public AddCommand(ReadOnlyPerson person) { + public AddCommand(Person person) { toAdd = new Person(person); } diff --git a/src/main/java/seedu/address/logic/commands/DeleteCommand.java b/src/main/java/seedu/address/logic/commands/DeleteCommand.java index 572ad734818d..14142e012906 100644 --- a/src/main/java/seedu/address/logic/commands/DeleteCommand.java +++ b/src/main/java/seedu/address/logic/commands/DeleteCommand.java @@ -5,7 +5,7 @@ import seedu.address.commons.core.Messages; import seedu.address.commons.core.index.Index; import seedu.address.logic.commands.exceptions.CommandException; -import seedu.address.model.person.ReadOnlyPerson; +import seedu.address.model.person.Person; import seedu.address.model.person.exceptions.PersonNotFoundException; /** @@ -32,13 +32,13 @@ public DeleteCommand(Index targetIndex) { @Override public CommandResult executeUndoableCommand() throws CommandException { - List lastShownList = model.getFilteredPersonList(); + List lastShownList = model.getFilteredPersonList(); if (targetIndex.getZeroBased() >= lastShownList.size()) { throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); } - ReadOnlyPerson personToDelete = lastShownList.get(targetIndex.getZeroBased()); + Person personToDelete = lastShownList.get(targetIndex.getZeroBased()); try { model.deletePerson(personToDelete); diff --git a/src/main/java/seedu/address/logic/commands/EditCommand.java b/src/main/java/seedu/address/logic/commands/EditCommand.java index 04bfb8d7283a..95c94d80e5fe 100644 --- a/src/main/java/seedu/address/logic/commands/EditCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditCommand.java @@ -21,7 +21,6 @@ import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; -import seedu.address.model.person.ReadOnlyPerson; import seedu.address.model.person.exceptions.DuplicatePersonException; import seedu.address.model.person.exceptions.PersonNotFoundException; import seedu.address.model.tag.Tag; @@ -67,13 +66,13 @@ public EditCommand(Index index, EditPersonDescriptor editPersonDescriptor) { @Override public CommandResult executeUndoableCommand() throws CommandException { - List lastShownList = model.getFilteredPersonList(); + List lastShownList = model.getFilteredPersonList(); if (index.getZeroBased() >= lastShownList.size()) { throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); } - ReadOnlyPerson personToEdit = lastShownList.get(index.getZeroBased()); + Person personToEdit = lastShownList.get(index.getZeroBased()); Person editedPerson = createEditedPerson(personToEdit, editPersonDescriptor); try { @@ -91,8 +90,7 @@ public CommandResult executeUndoableCommand() throws CommandException { * Creates and returns a {@code Person} with the details of {@code personToEdit} * edited with {@code editPersonDescriptor}. */ - private static Person createEditedPerson(ReadOnlyPerson personToEdit, - EditPersonDescriptor editPersonDescriptor) { + private static Person createEditedPerson(Person personToEdit, EditPersonDescriptor editPersonDescriptor) { assert personToEdit != null; Name updatedName = editPersonDescriptor.getName().orElse(personToEdit.getName()); diff --git a/src/main/java/seedu/address/logic/commands/SelectCommand.java b/src/main/java/seedu/address/logic/commands/SelectCommand.java index 8ea9de621e16..9e3840a9dde6 100644 --- a/src/main/java/seedu/address/logic/commands/SelectCommand.java +++ b/src/main/java/seedu/address/logic/commands/SelectCommand.java @@ -7,7 +7,7 @@ import seedu.address.commons.core.index.Index; import seedu.address.commons.events.ui.JumpToListRequestEvent; import seedu.address.logic.commands.exceptions.CommandException; -import seedu.address.model.person.ReadOnlyPerson; +import seedu.address.model.person.Person; /** * Selects a person identified using it's last displayed index from the address book. @@ -32,7 +32,7 @@ public SelectCommand(Index targetIndex) { @Override public CommandResult execute() throws CommandException { - List lastShownList = model.getFilteredPersonList(); + List lastShownList = model.getFilteredPersonList(); if (targetIndex.getZeroBased() >= lastShownList.size()) { throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); diff --git a/src/main/java/seedu/address/logic/parser/AddCommandParser.java b/src/main/java/seedu/address/logic/parser/AddCommandParser.java index ece2bb7bbf28..3c729b388554 100644 --- a/src/main/java/seedu/address/logic/parser/AddCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddCommandParser.java @@ -18,7 +18,6 @@ import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; -import seedu.address.model.person.ReadOnlyPerson; import seedu.address.model.tag.Tag; /** @@ -47,7 +46,7 @@ public AddCommand parse(String args) throws ParseException { Address address = ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS)).get(); Set tagList = ParserUtil.parseTags(argMultimap.getAllValues(PREFIX_TAG)); - ReadOnlyPerson person = new Person(name, phone, email, address, tagList); + Person person = new Person(name, phone, email, address, tagList); return new AddCommand(person); } catch (IllegalValueException ive) { diff --git a/src/main/java/seedu/address/model/AddressBook.java b/src/main/java/seedu/address/model/AddressBook.java index 597c80179596..f8d0260de159 100644 --- a/src/main/java/seedu/address/model/AddressBook.java +++ b/src/main/java/seedu/address/model/AddressBook.java @@ -12,7 +12,6 @@ import javafx.collections.ObservableList; import seedu.address.model.person.Person; -import seedu.address.model.person.ReadOnlyPerson; import seedu.address.model.person.UniquePersonList; import seedu.address.model.person.exceptions.DuplicatePersonException; import seedu.address.model.person.exceptions.PersonNotFoundException; @@ -52,7 +51,7 @@ public AddressBook(ReadOnlyAddressBook toBeCopied) { //// list overwrite operations - public void setPersons(List persons) throws DuplicatePersonException { + public void setPersons(List persons) throws DuplicatePersonException { this.persons.setPersons(persons); } @@ -86,7 +85,7 @@ public void resetData(ReadOnlyAddressBook newData) { * * @throws DuplicatePersonException if an equivalent person already exists. */ - public void addPerson(ReadOnlyPerson p) throws DuplicatePersonException { + public void addPerson(Person p) throws DuplicatePersonException { Person person = syncWithMasterTagList(p); // TODO: the tags master list will be updated even though the below line fails. // This can cause the tags master list to have additional tags that are not tagged to any person @@ -95,24 +94,24 @@ public void addPerson(ReadOnlyPerson p) throws DuplicatePersonException { } /** - * Replaces the given person {@code target} in the list with {@code editedReadOnlyPerson}. - * {@code AddressBook}'s tag list will be updated with the tags of {@code editedReadOnlyPerson}. + * Replaces the given person {@code target} in the list with {@code editedPerson}. + * {@code AddressBook}'s tag list will be updated with the tags of {@code editedPerson}. * * @throws DuplicatePersonException if updating the person's details causes the person to be equivalent to * another existing person in the list. * @throws PersonNotFoundException if {@code target} could not be found in the list. * - * @see #syncWithMasterTagList(ReadOnlyPerson) + * @see #syncWithMasterTagList(Person) */ - public void updatePerson(ReadOnlyPerson target, ReadOnlyPerson editedReadOnlyPerson) + public void updatePerson(Person target, Person editedPerson) throws DuplicatePersonException, PersonNotFoundException { - requireNonNull(editedReadOnlyPerson); + requireNonNull(editedPerson); - Person editedPerson = syncWithMasterTagList(editedReadOnlyPerson); + Person syncedEditedPerson = syncWithMasterTagList(editedPerson); // TODO: the tags master list will be updated even though the below line fails. // This can cause the tags master list to have additional tags that are not tagged to any person // in the person list. - persons.setPerson(target, editedPerson); + persons.setPerson(target, syncedEditedPerson); } /** @@ -120,7 +119,7 @@ public void updatePerson(ReadOnlyPerson target, ReadOnlyPerson editedReadOnlyPer * @return a copy of this {@code person} such that every tag in this person points to a Tag object in the master * list. */ - private Person syncWithMasterTagList(ReadOnlyPerson person) { + private Person syncWithMasterTagList(Person person) { final UniqueTagList personTags = new UniqueTagList(person.getTags()); tags.mergeFrom(personTags); @@ -140,7 +139,7 @@ private Person syncWithMasterTagList(ReadOnlyPerson person) { * Removes {@code key} from this {@code AddressBook}. * @throws PersonNotFoundException if the {@code key} is not in this {@code AddressBook}. */ - public boolean removePerson(ReadOnlyPerson key) throws PersonNotFoundException { + public boolean removePerson(Person key) throws PersonNotFoundException { if (persons.remove(key)) { return true; } else { @@ -163,7 +162,7 @@ public String toString() { } @Override - public ObservableList getPersonList() { + public ObservableList getPersonList() { return persons.asObservableList(); } diff --git a/src/main/java/seedu/address/model/Model.java b/src/main/java/seedu/address/model/Model.java index 9c6aa4e766a0..4a6079ce0199 100644 --- a/src/main/java/seedu/address/model/Model.java +++ b/src/main/java/seedu/address/model/Model.java @@ -3,7 +3,7 @@ import java.util.function.Predicate; import javafx.collections.ObservableList; -import seedu.address.model.person.ReadOnlyPerson; +import seedu.address.model.person.Person; import seedu.address.model.person.exceptions.DuplicatePersonException; import seedu.address.model.person.exceptions.PersonNotFoundException; @@ -12,7 +12,7 @@ */ public interface Model { /** {@code Predicate} that always evaluate to true */ - Predicate PREDICATE_SHOW_ALL_PERSONS = unused -> true; + Predicate PREDICATE_SHOW_ALL_PERSONS = unused -> true; /** Clears existing backing model and replaces with the provided new data. */ void resetData(ReadOnlyAddressBook newData); @@ -21,10 +21,10 @@ public interface Model { ReadOnlyAddressBook getAddressBook(); /** Deletes the given person. */ - void deletePerson(ReadOnlyPerson target) throws PersonNotFoundException; + void deletePerson(Person target) throws PersonNotFoundException; /** Adds the given person */ - void addPerson(ReadOnlyPerson person) throws DuplicatePersonException; + void addPerson(Person person) throws DuplicatePersonException; /** * Replaces the given person {@code target} with {@code editedPerson}. @@ -33,16 +33,16 @@ public interface Model { * another existing person in the list. * @throws PersonNotFoundException if {@code target} could not be found in the list. */ - void updatePerson(ReadOnlyPerson target, ReadOnlyPerson editedPerson) + void updatePerson(Person target, Person editedPerson) throws DuplicatePersonException, PersonNotFoundException; /** Returns an unmodifiable view of the filtered person list */ - ObservableList getFilteredPersonList(); + ObservableList getFilteredPersonList(); /** * Updates the filter of the filtered person list to filter by the given {@code predicate}. * @throws NullPointerException if {@code predicate} is null. */ - void updateFilteredPersonList(Predicate predicate); + void updateFilteredPersonList(Predicate predicate); } diff --git a/src/main/java/seedu/address/model/ModelManager.java b/src/main/java/seedu/address/model/ModelManager.java index 095c831cfbf8..22a7d0eb3f4d 100644 --- a/src/main/java/seedu/address/model/ModelManager.java +++ b/src/main/java/seedu/address/model/ModelManager.java @@ -12,7 +12,7 @@ import seedu.address.commons.core.ComponentManager; import seedu.address.commons.core.LogsCenter; import seedu.address.commons.events.model.AddressBookChangedEvent; -import seedu.address.model.person.ReadOnlyPerson; +import seedu.address.model.person.Person; import seedu.address.model.person.exceptions.DuplicatePersonException; import seedu.address.model.person.exceptions.PersonNotFoundException; @@ -24,7 +24,7 @@ public class ModelManager extends ComponentManager implements Model { private static final Logger logger = LogsCenter.getLogger(ModelManager.class); private final AddressBook addressBook; - private final FilteredList filteredPersons; + private final FilteredList filteredPersons; /** * Initializes a ModelManager with the given addressBook and userPrefs. @@ -60,20 +60,20 @@ private void indicateAddressBookChanged() { } @Override - public synchronized void deletePerson(ReadOnlyPerson target) throws PersonNotFoundException { + public synchronized void deletePerson(Person target) throws PersonNotFoundException { addressBook.removePerson(target); indicateAddressBookChanged(); } @Override - public synchronized void addPerson(ReadOnlyPerson person) throws DuplicatePersonException { + public synchronized void addPerson(Person person) throws DuplicatePersonException { addressBook.addPerson(person); updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); indicateAddressBookChanged(); } @Override - public void updatePerson(ReadOnlyPerson target, ReadOnlyPerson editedPerson) + public void updatePerson(Person target, Person editedPerson) throws DuplicatePersonException, PersonNotFoundException { requireAllNonNull(target, editedPerson); @@ -84,16 +84,16 @@ public void updatePerson(ReadOnlyPerson target, ReadOnlyPerson editedPerson) //=========== Filtered Person List Accessors ============================================================= /** - * Returns an unmodifiable view of the list of {@code ReadOnlyPerson} backed by the internal list of + * Returns an unmodifiable view of the list of {@code Person} backed by the internal list of * {@code addressBook} */ @Override - public ObservableList getFilteredPersonList() { + public ObservableList getFilteredPersonList() { return FXCollections.unmodifiableObservableList(filteredPersons); } @Override - public void updateFilteredPersonList(Predicate predicate) { + public void updateFilteredPersonList(Predicate predicate) { requireNonNull(predicate); filteredPersons.setPredicate(predicate); } diff --git a/src/main/java/seedu/address/model/ReadOnlyAddressBook.java b/src/main/java/seedu/address/model/ReadOnlyAddressBook.java index df24c7d9e928..1f4e49a37d67 100644 --- a/src/main/java/seedu/address/model/ReadOnlyAddressBook.java +++ b/src/main/java/seedu/address/model/ReadOnlyAddressBook.java @@ -1,7 +1,7 @@ package seedu.address.model; import javafx.collections.ObservableList; -import seedu.address.model.person.ReadOnlyPerson; +import seedu.address.model.person.Person; import seedu.address.model.tag.Tag; /** @@ -13,7 +13,7 @@ public interface ReadOnlyAddressBook { * Returns an unmodifiable view of the persons list. * This list will not contain any duplicate persons. */ - ObservableList getPersonList(); + ObservableList getPersonList(); /** * Returns an unmodifiable view of the tags list. diff --git a/src/main/java/seedu/address/model/person/NameContainsKeywordsPredicate.java b/src/main/java/seedu/address/model/person/NameContainsKeywordsPredicate.java index 9d73fd178b0f..827e2cc106bd 100644 --- a/src/main/java/seedu/address/model/person/NameContainsKeywordsPredicate.java +++ b/src/main/java/seedu/address/model/person/NameContainsKeywordsPredicate.java @@ -6,9 +6,9 @@ import seedu.address.commons.util.StringUtil; /** - * Tests that a {@code ReadOnlyPerson}'s {@code Name} matches any of the keywords given. + * Tests that a {@code Person}'s {@code Name} matches any of the keywords given. */ -public class NameContainsKeywordsPredicate implements Predicate { +public class NameContainsKeywordsPredicate implements Predicate { private final List keywords; public NameContainsKeywordsPredicate(List keywords) { @@ -16,7 +16,7 @@ public NameContainsKeywordsPredicate(List keywords) { } @Override - public boolean test(ReadOnlyPerson person) { + public boolean test(Person person) { return keywords.stream() .anyMatch(keyword -> StringUtil.containsWordIgnoreCase(person.getName().fullName, keyword)); } diff --git a/src/main/java/seedu/address/model/person/Person.java b/src/main/java/seedu/address/model/person/Person.java index 5406f6029489..284e26df2c64 100644 --- a/src/main/java/seedu/address/model/person/Person.java +++ b/src/main/java/seedu/address/model/person/Person.java @@ -13,7 +13,7 @@ * Represents a Person in the address book. * Guarantees: details are present and not null, field values are validated, immutable. */ -public class Person implements ReadOnlyPerson { +public class Person { private final Name name; private final Phone phone; @@ -36,29 +36,25 @@ public Person(Name name, Phone phone, Email email, Address address, Set tag } /** - * Creates a copy of the given ReadOnlyPerson. + * Creates a copy of the given Person. */ - public Person(ReadOnlyPerson source) { + public Person(Person source) { this(source.getName(), source.getPhone(), source.getEmail(), source.getAddress(), source.getTags()); } - @Override public Name getName() { return name; } - @Override public Phone getPhone() { return phone; } - @Override public Email getEmail() { return email; } - @Override public Address getAddress() { return address; } @@ -67,7 +63,6 @@ public Address getAddress() { * Returns an immutable tag set, which throws {@code UnsupportedOperationException} * if modification is attempted. */ - @Override public Set getTags() { return Collections.unmodifiableSet(tags.toSet()); } diff --git a/src/main/java/seedu/address/model/person/ReadOnlyPerson.java b/src/main/java/seedu/address/model/person/ReadOnlyPerson.java deleted file mode 100644 index 9067380adbea..000000000000 --- a/src/main/java/seedu/address/model/person/ReadOnlyPerson.java +++ /dev/null @@ -1,18 +0,0 @@ -package seedu.address.model.person; - -import java.util.Set; - -import seedu.address.model.tag.Tag; - -/** - * A read-only immutable interface for a Person in the addressbook. - * Implementations should guarantee: details are present and not null, field values are validated. - */ -public interface ReadOnlyPerson { - - Name getName(); - Phone getPhone(); - Email getEmail(); - Address getAddress(); - Set getTags(); -} diff --git a/src/main/java/seedu/address/model/person/UniquePersonList.java b/src/main/java/seedu/address/model/person/UniquePersonList.java index 3b293a9d2b80..8dc6b07fdaeb 100644 --- a/src/main/java/seedu/address/model/person/UniquePersonList.java +++ b/src/main/java/seedu/address/model/person/UniquePersonList.java @@ -25,12 +25,12 @@ public class UniquePersonList implements Iterable { private final ObservableList internalList = FXCollections.observableArrayList(); // used by asObservableList() - private final ObservableList mappedList = EasyBind.map(internalList, (person) -> person); + private final ObservableList mappedList = EasyBind.map(internalList, (person) -> person); /** * Returns true if the list contains an equivalent person as the given argument. */ - public boolean contains(ReadOnlyPerson toCheck) { + public boolean contains(Person toCheck) { requireNonNull(toCheck); return internalList.contains(toCheck); } @@ -40,7 +40,7 @@ public boolean contains(ReadOnlyPerson toCheck) { * * @throws DuplicatePersonException if the person to add is a duplicate of an existing person in the list. */ - public void add(ReadOnlyPerson toAdd) throws DuplicatePersonException { + public void add(Person toAdd) throws DuplicatePersonException { requireNonNull(toAdd); if (contains(toAdd)) { throw new DuplicatePersonException(); @@ -54,7 +54,7 @@ public void add(ReadOnlyPerson toAdd) throws DuplicatePersonException { * @throws DuplicatePersonException if the replacement is equivalent to another existing person in the list. * @throws PersonNotFoundException if {@code target} could not be found in the list. */ - public void setPerson(ReadOnlyPerson target, ReadOnlyPerson editedPerson) + public void setPerson(Person target, Person editedPerson) throws DuplicatePersonException, PersonNotFoundException { requireNonNull(editedPerson); @@ -75,7 +75,7 @@ public void setPerson(ReadOnlyPerson target, ReadOnlyPerson editedPerson) * * @throws PersonNotFoundException if no such person could be found in the list. */ - public boolean remove(ReadOnlyPerson toRemove) throws PersonNotFoundException { + public boolean remove(Person toRemove) throws PersonNotFoundException { requireNonNull(toRemove); final boolean personFoundAndDeleted = internalList.remove(toRemove); if (!personFoundAndDeleted) { @@ -88,9 +88,9 @@ public void setPersons(UniquePersonList replacement) { this.internalList.setAll(replacement.internalList); } - public void setPersons(List persons) throws DuplicatePersonException { + public void setPersons(List persons) throws DuplicatePersonException { final UniquePersonList replacement = new UniquePersonList(); - for (final ReadOnlyPerson person : persons) { + for (final Person person : persons) { replacement.add(new Person(person)); } setPersons(replacement); @@ -99,7 +99,7 @@ public void setPersons(List persons) throws DuplicateP /** * Returns the backing list as an unmodifiable {@code ObservableList}. */ - public ObservableList asObservableList() { + public ObservableList asObservableList() { return FXCollections.unmodifiableObservableList(mappedList); } diff --git a/src/main/java/seedu/address/storage/XmlAdaptedPerson.java b/src/main/java/seedu/address/storage/XmlAdaptedPerson.java index 5e833226e2b1..87120ddbaa5a 100644 --- a/src/main/java/seedu/address/storage/XmlAdaptedPerson.java +++ b/src/main/java/seedu/address/storage/XmlAdaptedPerson.java @@ -13,7 +13,6 @@ import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; -import seedu.address.model.person.ReadOnlyPerson; import seedu.address.model.tag.Tag; /** @@ -57,7 +56,7 @@ public XmlAdaptedPerson(String name, String phone, String email, String address, * * @param source future changes to this will not affect the created XmlAdaptedPerson */ - public XmlAdaptedPerson(ReadOnlyPerson source) { + public XmlAdaptedPerson(Person source) { name = source.getName().fullName; phone = source.getPhone().value; email = source.getEmail().value; diff --git a/src/main/java/seedu/address/storage/XmlSerializableAddressBook.java b/src/main/java/seedu/address/storage/XmlSerializableAddressBook.java index 37eaee382ce4..50f6ee4af6e5 100644 --- a/src/main/java/seedu/address/storage/XmlSerializableAddressBook.java +++ b/src/main/java/seedu/address/storage/XmlSerializableAddressBook.java @@ -11,7 +11,7 @@ import javafx.collections.ObservableList; import seedu.address.commons.exceptions.IllegalValueException; import seedu.address.model.ReadOnlyAddressBook; -import seedu.address.model.person.ReadOnlyPerson; +import seedu.address.model.person.Person; import seedu.address.model.tag.Tag; /** @@ -44,8 +44,8 @@ public XmlSerializableAddressBook(ReadOnlyAddressBook src) { } @Override - public ObservableList getPersonList() { - final ObservableList persons = this.persons.stream().map(p -> { + public ObservableList getPersonList() { + final ObservableList persons = this.persons.stream().map(p -> { try { return p.toModelType(); } catch (IllegalValueException e) { diff --git a/src/main/java/seedu/address/ui/BrowserPanel.java b/src/main/java/seedu/address/ui/BrowserPanel.java index 98689931eb17..1d964dfc6d46 100644 --- a/src/main/java/seedu/address/ui/BrowserPanel.java +++ b/src/main/java/seedu/address/ui/BrowserPanel.java @@ -13,7 +13,7 @@ import seedu.address.MainApp; import seedu.address.commons.core.LogsCenter; import seedu.address.commons.events.ui.PersonPanelSelectionChangedEvent; -import seedu.address.model.person.ReadOnlyPerson; +import seedu.address.model.person.Person; /** * The Browser Panel of the App. @@ -41,7 +41,7 @@ public BrowserPanel() { registerAsAnEventHandler(this); } - private void loadPersonPage(ReadOnlyPerson person) { + private void loadPersonPage(Person person) { loadPage(GOOGLE_SEARCH_URL_PREFIX + person.getName().fullName.replaceAll(" ", "+") + GOOGLE_SEARCH_URL_SUFFIX); } diff --git a/src/main/java/seedu/address/ui/PersonCard.java b/src/main/java/seedu/address/ui/PersonCard.java index f086e1ca8a2a..f6727ea83abd 100644 --- a/src/main/java/seedu/address/ui/PersonCard.java +++ b/src/main/java/seedu/address/ui/PersonCard.java @@ -5,7 +5,7 @@ import javafx.scene.layout.FlowPane; import javafx.scene.layout.HBox; import javafx.scene.layout.Region; -import seedu.address.model.person.ReadOnlyPerson; +import seedu.address.model.person.Person; /** * An UI component that displays information of a {@code Person}. @@ -22,7 +22,7 @@ public class PersonCard extends UiPart { * @see The issue on AddressBook level 4 */ - public final ReadOnlyPerson person; + public final Person person; @FXML private HBox cardPane; @@ -39,7 +39,7 @@ public class PersonCard extends UiPart { @FXML private FlowPane tags; - public PersonCard(ReadOnlyPerson person, int displayedIndex) { + public PersonCard(Person person, int displayedIndex) { super(FXML); this.person = person; id.setText(displayedIndex + ". "); diff --git a/src/main/java/seedu/address/ui/PersonListPanel.java b/src/main/java/seedu/address/ui/PersonListPanel.java index d3a5fbae42bb..60a4f70f4e71 100644 --- a/src/main/java/seedu/address/ui/PersonListPanel.java +++ b/src/main/java/seedu/address/ui/PersonListPanel.java @@ -15,7 +15,7 @@ import seedu.address.commons.core.LogsCenter; import seedu.address.commons.events.ui.JumpToListRequestEvent; import seedu.address.commons.events.ui.PersonPanelSelectionChangedEvent; -import seedu.address.model.person.ReadOnlyPerson; +import seedu.address.model.person.Person; /** * Panel containing the list of persons. @@ -27,13 +27,13 @@ public class PersonListPanel extends UiPart { @FXML private ListView personListView; - public PersonListPanel(ObservableList personList) { + public PersonListPanel(ObservableList personList) { super(FXML); setConnections(personList); registerAsAnEventHandler(this); } - private void setConnections(ObservableList personList) { + private void setConnections(ObservableList personList) { ObservableList mappedList = EasyBind.map( personList, (person) -> new PersonCard(person, personList.indexOf(person) + 1)); personListView.setItems(mappedList); diff --git a/src/test/java/guitests/guihandles/PersonListPanelHandle.java b/src/test/java/guitests/guihandles/PersonListPanelHandle.java index c6a1f5dc1df9..40564bb2d960 100644 --- a/src/test/java/guitests/guihandles/PersonListPanelHandle.java +++ b/src/test/java/guitests/guihandles/PersonListPanelHandle.java @@ -4,7 +4,7 @@ import java.util.Optional; import javafx.scene.control.ListView; -import seedu.address.model.person.ReadOnlyPerson; +import seedu.address.model.person.Person; import seedu.address.ui.PersonCard; /** @@ -57,7 +57,7 @@ public boolean isAnyCardSelected() { /** * Navigates the listview to display and select the person. */ - public void navigateToCard(ReadOnlyPerson person) { + public void navigateToCard(Person person) { List cards = getRootNode().getItems(); Optional matchingCard = cards.stream().filter(card -> card.person.equals(person)).findFirst(); @@ -82,7 +82,7 @@ public PersonCardHandle getPersonCardHandle(int index) { /** * Returns the {@code PersonCardHandle} of the specified {@code person} in the list. */ - public PersonCardHandle getPersonCardHandle(ReadOnlyPerson person) { + public PersonCardHandle getPersonCardHandle(Person person) { Optional handle = getRootNode().getItems().stream() .filter(card -> card.person.equals(person)) .map(card -> new PersonCardHandle(card.getRoot())) diff --git a/src/test/java/seedu/address/logic/commands/AddCommandTest.java b/src/test/java/seedu/address/logic/commands/AddCommandTest.java index b327ef2d805b..9cd58cfdbc25 100644 --- a/src/test/java/seedu/address/logic/commands/AddCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/AddCommandTest.java @@ -21,7 +21,6 @@ import seedu.address.model.Model; import seedu.address.model.ReadOnlyAddressBook; import seedu.address.model.person.Person; -import seedu.address.model.person.ReadOnlyPerson; import seedu.address.model.person.exceptions.DuplicatePersonException; import seedu.address.model.person.exceptions.PersonNotFoundException; import seedu.address.testutil.PersonBuilder; @@ -97,7 +96,7 @@ private AddCommand getAddCommandForPerson(Person person, Model model) { */ private class ModelStub implements Model { @Override - public void addPerson(ReadOnlyPerson person) throws DuplicatePersonException { + public void addPerson(Person person) throws DuplicatePersonException { fail("This method should not be called."); } @@ -113,24 +112,24 @@ public ReadOnlyAddressBook getAddressBook() { } @Override - public void deletePerson(ReadOnlyPerson target) throws PersonNotFoundException { + public void deletePerson(Person target) throws PersonNotFoundException { fail("This method should not be called."); } @Override - public void updatePerson(ReadOnlyPerson target, ReadOnlyPerson editedPerson) + public void updatePerson(Person target, Person editedPerson) throws DuplicatePersonException { fail("This method should not be called."); } @Override - public ObservableList getFilteredPersonList() { + public ObservableList getFilteredPersonList() { fail("This method should not be called."); return null; } @Override - public void updateFilteredPersonList(Predicate predicate) { + public void updateFilteredPersonList(Predicate predicate) { fail("This method should not be called."); } } @@ -140,7 +139,7 @@ public void updateFilteredPersonList(Predicate predicate) { */ private class ModelStubThrowingDuplicatePersonException extends ModelStub { @Override - public void addPerson(ReadOnlyPerson person) throws DuplicatePersonException { + public void addPerson(Person person) throws DuplicatePersonException { throw new DuplicatePersonException(); } @@ -157,7 +156,7 @@ private class ModelStubAcceptingPersonAdded extends ModelStub { final ArrayList personsAdded = new ArrayList<>(); @Override - public void addPerson(ReadOnlyPerson person) throws DuplicatePersonException { + public void addPerson(Person person) throws DuplicatePersonException { personsAdded.add(new Person(person)); } diff --git a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java index f1097b06111e..b906d895edb5 100644 --- a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java +++ b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java @@ -16,7 +16,7 @@ import seedu.address.model.AddressBook; import seedu.address.model.Model; import seedu.address.model.person.NameContainsKeywordsPredicate; -import seedu.address.model.person.ReadOnlyPerson; +import seedu.address.model.person.Person; import seedu.address.model.person.exceptions.PersonNotFoundException; import seedu.address.testutil.EditPersonDescriptorBuilder; @@ -94,7 +94,7 @@ public static void assertCommandFailure(Command command, Model actualModel, Stri // we are unable to defensively copy the model for comparison later, so we can // only do so by copying its components. AddressBook expectedAddressBook = new AddressBook(actualModel.getAddressBook()); - List expectedFilteredList = new ArrayList<>(actualModel.getFilteredPersonList()); + List expectedFilteredList = new ArrayList<>(actualModel.getFilteredPersonList()); try { command.execute(); @@ -110,7 +110,7 @@ public static void assertCommandFailure(Command command, Model actualModel, Stri * Updates {@code model}'s filtered list to show only the first person in the {@code model}'s address book. */ public static void showFirstPersonOnly(Model model) { - ReadOnlyPerson person = model.getAddressBook().getPersonList().get(0); + Person person = model.getAddressBook().getPersonList().get(0); final String[] splitName = person.getName().fullName.split("\\s+"); model.updateFilteredPersonList(new NameContainsKeywordsPredicate(Arrays.asList(splitName[0]))); @@ -121,7 +121,7 @@ public static void showFirstPersonOnly(Model model) { * Deletes the first person in {@code model}'s filtered list from {@code model}'s address book. */ public static void deleteFirstPerson(Model model) { - ReadOnlyPerson firstPerson = model.getFilteredPersonList().get(0); + Person firstPerson = model.getFilteredPersonList().get(0); try { model.deletePerson(firstPerson); } catch (PersonNotFoundException pnfe) { diff --git a/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java b/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java index 0c4f645de0b2..04114d2a67d2 100644 --- a/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java @@ -18,7 +18,7 @@ import seedu.address.model.Model; import seedu.address.model.ModelManager; import seedu.address.model.UserPrefs; -import seedu.address.model.person.ReadOnlyPerson; +import seedu.address.model.person.Person; /** * Contains integration tests (interaction with the Model) and unit tests for {@code DeleteCommand}. @@ -29,7 +29,7 @@ public class DeleteCommandTest { @Test public void execute_validIndexUnfilteredList_success() throws Exception { - ReadOnlyPerson personToDelete = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); + Person personToDelete = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); DeleteCommand deleteCommand = prepareCommand(INDEX_FIRST_PERSON); String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_PERSON_SUCCESS, personToDelete); @@ -52,7 +52,7 @@ public void execute_invalidIndexUnfilteredList_throwsCommandException() throws E public void execute_validIndexFilteredList_success() throws Exception { showFirstPersonOnly(model); - ReadOnlyPerson personToDelete = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); + Person personToDelete = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); DeleteCommand deleteCommand = prepareCommand(INDEX_FIRST_PERSON); String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_PERSON_SUCCESS, personToDelete); diff --git a/src/test/java/seedu/address/logic/commands/EditCommandTest.java b/src/test/java/seedu/address/logic/commands/EditCommandTest.java index 4b08e679f824..cd2d772e026a 100644 --- a/src/test/java/seedu/address/logic/commands/EditCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/EditCommandTest.java @@ -26,7 +26,6 @@ import seedu.address.model.ModelManager; import seedu.address.model.UserPrefs; import seedu.address.model.person.Person; -import seedu.address.model.person.ReadOnlyPerson; import seedu.address.testutil.EditPersonDescriptorBuilder; import seedu.address.testutil.PersonBuilder; @@ -54,7 +53,7 @@ public void execute_allFieldsSpecifiedUnfilteredList_success() throws Exception @Test public void execute_someFieldsSpecifiedUnfilteredList_success() throws Exception { Index indexLastPerson = Index.fromOneBased(model.getFilteredPersonList().size()); - ReadOnlyPerson lastPerson = model.getFilteredPersonList().get(indexLastPerson.getZeroBased()); + Person lastPerson = model.getFilteredPersonList().get(indexLastPerson.getZeroBased()); PersonBuilder personInList = new PersonBuilder(lastPerson); Person editedPerson = personInList.withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) @@ -75,7 +74,7 @@ public void execute_someFieldsSpecifiedUnfilteredList_success() throws Exception @Test public void execute_noFieldSpecifiedUnfilteredList_success() { EditCommand editCommand = prepareCommand(INDEX_FIRST_PERSON, new EditPersonDescriptor()); - ReadOnlyPerson editedPerson = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); + Person editedPerson = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, editedPerson); @@ -88,7 +87,7 @@ public void execute_noFieldSpecifiedUnfilteredList_success() { public void execute_filteredList_success() throws Exception { showFirstPersonOnly(model); - ReadOnlyPerson personInFilteredList = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); + Person personInFilteredList = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); Person editedPerson = new PersonBuilder(personInFilteredList).withName(VALID_NAME_BOB).build(); EditCommand editCommand = prepareCommand(INDEX_FIRST_PERSON, new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB).build()); @@ -115,7 +114,7 @@ public void execute_duplicatePersonFilteredList_failure() { showFirstPersonOnly(model); // edit person in filtered list into a duplicate in address book - ReadOnlyPerson personInList = model.getAddressBook().getPersonList().get(INDEX_SECOND_PERSON.getZeroBased()); + Person personInList = model.getAddressBook().getPersonList().get(INDEX_SECOND_PERSON.getZeroBased()); EditCommand editCommand = prepareCommand(INDEX_FIRST_PERSON, new EditPersonDescriptorBuilder(personInList).build()); diff --git a/src/test/java/seedu/address/logic/commands/FindCommandTest.java b/src/test/java/seedu/address/logic/commands/FindCommandTest.java index 5386c8a3f515..dee1f007f751 100644 --- a/src/test/java/seedu/address/logic/commands/FindCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/FindCommandTest.java @@ -22,7 +22,7 @@ import seedu.address.model.ModelManager; import seedu.address.model.UserPrefs; import seedu.address.model.person.NameContainsKeywordsPredicate; -import seedu.address.model.person.ReadOnlyPerson; +import seedu.address.model.person.Person; /** * Contains integration tests (interaction with the Model) for {@code FindCommand}. @@ -84,10 +84,10 @@ private FindCommand prepareCommand(String userInput) { /** * Asserts that {@code command} is successfully executed, and
* - the command feedback is equal to {@code expectedMessage}
- * - the {@code FilteredList} is equal to {@code expectedList}
+ * - the {@code FilteredList} is equal to {@code expectedList}
* - the {@code AddressBook} in model remains the same after executing the {@code command} */ - private void assertCommandSuccess(FindCommand command, String expectedMessage, List expectedList) { + private void assertCommandSuccess(FindCommand command, String expectedMessage, List expectedList) { AddressBook expectedAddressBook = new AddressBook(model.getAddressBook()); CommandResult commandResult = command.execute(); diff --git a/src/test/java/seedu/address/logic/commands/UndoableCommandTest.java b/src/test/java/seedu/address/logic/commands/UndoableCommandTest.java index 41d97ab15c60..7014654a8450 100644 --- a/src/test/java/seedu/address/logic/commands/UndoableCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/UndoableCommandTest.java @@ -12,7 +12,7 @@ import seedu.address.model.Model; import seedu.address.model.ModelManager; import seedu.address.model.UserPrefs; -import seedu.address.model.person.ReadOnlyPerson; +import seedu.address.model.person.Person; import seedu.address.model.person.exceptions.PersonNotFoundException; public class UndoableCommandTest { @@ -55,7 +55,7 @@ class DummyCommand extends UndoableCommand { @Override public CommandResult executeUndoableCommand() throws CommandException { - ReadOnlyPerson personToDelete = model.getFilteredPersonList().get(0); + Person personToDelete = model.getFilteredPersonList().get(0); try { model.deletePerson(personToDelete); } catch (PersonNotFoundException pnfe) { diff --git a/src/test/java/seedu/address/model/AddressBookTest.java b/src/test/java/seedu/address/model/AddressBookTest.java index 49633ed9774d..dfd31c93fab3 100644 --- a/src/test/java/seedu/address/model/AddressBookTest.java +++ b/src/test/java/seedu/address/model/AddressBookTest.java @@ -17,7 +17,6 @@ import javafx.collections.FXCollections; import javafx.collections.ObservableList; import seedu.address.model.person.Person; -import seedu.address.model.person.ReadOnlyPerson; import seedu.address.model.tag.Tag; public class AddressBookTest { @@ -73,16 +72,16 @@ public void getTagList_modifyList_throwsUnsupportedOperationException() { * A stub ReadOnlyAddressBook whose persons and tags lists can violate interface constraints. */ private static class AddressBookStub implements ReadOnlyAddressBook { - private final ObservableList persons = FXCollections.observableArrayList(); + private final ObservableList persons = FXCollections.observableArrayList(); private final ObservableList tags = FXCollections.observableArrayList(); - AddressBookStub(Collection persons, Collection tags) { + AddressBookStub(Collection persons, Collection tags) { this.persons.setAll(persons); this.tags.setAll(tags); } @Override - public ObservableList getPersonList() { + public ObservableList getPersonList() { return persons; } diff --git a/src/test/java/seedu/address/testutil/AddressBookBuilder.java b/src/test/java/seedu/address/testutil/AddressBookBuilder.java index bdae2555c27d..6e73a762b0c1 100644 --- a/src/test/java/seedu/address/testutil/AddressBookBuilder.java +++ b/src/test/java/seedu/address/testutil/AddressBookBuilder.java @@ -2,7 +2,7 @@ import seedu.address.commons.exceptions.IllegalValueException; import seedu.address.model.AddressBook; -import seedu.address.model.person.ReadOnlyPerson; +import seedu.address.model.person.Person; import seedu.address.model.person.exceptions.DuplicatePersonException; import seedu.address.model.tag.Tag; @@ -26,7 +26,7 @@ public AddressBookBuilder(AddressBook addressBook) { /** * Adds a new {@code Person} to the {@code AddressBook} that we are building. */ - public AddressBookBuilder withPerson(ReadOnlyPerson person) { + public AddressBookBuilder withPerson(Person person) { try { addressBook.addPerson(person); } catch (DuplicatePersonException dpe) { diff --git a/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java b/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java index a5bbb6d91940..4584bd5044e1 100644 --- a/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java +++ b/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java @@ -8,8 +8,8 @@ import seedu.address.model.person.Address; import seedu.address.model.person.Email; import seedu.address.model.person.Name; +import seedu.address.model.person.Person; import seedu.address.model.person.Phone; -import seedu.address.model.person.ReadOnlyPerson; import seedu.address.model.tag.Tag; /** @@ -30,7 +30,7 @@ public EditPersonDescriptorBuilder(EditPersonDescriptor descriptor) { /** * Returns an {@code EditPersonDescriptor} with fields containing {@code person}'s details */ - public EditPersonDescriptorBuilder(ReadOnlyPerson person) { + public EditPersonDescriptorBuilder(Person person) { descriptor = new EditPersonDescriptor(); descriptor.setName(person.getName()); descriptor.setPhone(person.getPhone()); diff --git a/src/test/java/seedu/address/testutil/PersonBuilder.java b/src/test/java/seedu/address/testutil/PersonBuilder.java index 5f76c32747a2..b124fc1d73b1 100644 --- a/src/test/java/seedu/address/testutil/PersonBuilder.java +++ b/src/test/java/seedu/address/testutil/PersonBuilder.java @@ -8,7 +8,6 @@ import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; -import seedu.address.model.person.ReadOnlyPerson; import seedu.address.model.tag.Tag; import seedu.address.model.util.SampleDataUtil; @@ -40,7 +39,7 @@ public PersonBuilder() { /** * Initializes the PersonBuilder with the data of {@code personToCopy}. */ - public PersonBuilder(ReadOnlyPerson personToCopy) { + public PersonBuilder(Person personToCopy) { name = personToCopy.getName(); phone = personToCopy.getPhone(); email = personToCopy.getEmail(); diff --git a/src/test/java/seedu/address/testutil/PersonUtil.java b/src/test/java/seedu/address/testutil/PersonUtil.java index dee6522780af..642d4f174514 100644 --- a/src/test/java/seedu/address/testutil/PersonUtil.java +++ b/src/test/java/seedu/address/testutil/PersonUtil.java @@ -7,7 +7,7 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; import seedu.address.logic.commands.AddCommand; -import seedu.address.model.person.ReadOnlyPerson; +import seedu.address.model.person.Person; /** * A utility class for Person. @@ -17,14 +17,14 @@ public class PersonUtil { /** * Returns an add command string for adding the {@code person}. */ - public static String getAddCommand(ReadOnlyPerson person) { + public static String getAddCommand(Person person) { return AddCommand.COMMAND_WORD + " " + getPersonDetails(person); } /** * Returns the part of command string for the given {@code person}'s details. */ - public static String getPersonDetails(ReadOnlyPerson person) { + public static String getPersonDetails(Person person) { StringBuilder sb = new StringBuilder(); sb.append(PREFIX_NAME + person.getName().fullName + " "); sb.append(PREFIX_PHONE + person.getPhone().value + " "); diff --git a/src/test/java/seedu/address/testutil/TestUtil.java b/src/test/java/seedu/address/testutil/TestUtil.java index 29e457791c8b..c1458738c054 100644 --- a/src/test/java/seedu/address/testutil/TestUtil.java +++ b/src/test/java/seedu/address/testutil/TestUtil.java @@ -6,7 +6,7 @@ import seedu.address.commons.core.index.Index; import seedu.address.commons.util.FileUtil; import seedu.address.model.Model; -import seedu.address.model.person.ReadOnlyPerson; +import seedu.address.model.person.Person; /** * A utility class for test cases. @@ -48,7 +48,7 @@ public static Index getLastIndex(Model model) { /** * Returns the person in the {@code model}'s person list at {@code index}. */ - public static ReadOnlyPerson getPerson(Model model, Index index) { + public static Person getPerson(Model model, Index index) { return model.getAddressBook().getPersonList().get(index.getZeroBased()); } } diff --git a/src/test/java/seedu/address/testutil/TypicalPersons.java b/src/test/java/seedu/address/testutil/TypicalPersons.java index 11144bfd356c..6d7bdbfc55ed 100644 --- a/src/test/java/seedu/address/testutil/TypicalPersons.java +++ b/src/test/java/seedu/address/testutil/TypicalPersons.java @@ -16,7 +16,7 @@ import java.util.List; import seedu.address.model.AddressBook; -import seedu.address.model.person.ReadOnlyPerson; +import seedu.address.model.person.Person; import seedu.address.model.person.exceptions.DuplicatePersonException; /** @@ -24,35 +24,35 @@ */ public class TypicalPersons { - public static final ReadOnlyPerson ALICE = new PersonBuilder().withName("Alice Pauline") + public static final Person ALICE = new PersonBuilder().withName("Alice Pauline") .withAddress("123, Jurong West Ave 6, #08-111").withEmail("alice@example.com") .withPhone("85355255") .withTags("friends").build(); - public static final ReadOnlyPerson BENSON = new PersonBuilder().withName("Benson Meier") + public static final Person BENSON = new PersonBuilder().withName("Benson Meier") .withAddress("311, Clementi Ave 2, #02-25") .withEmail("johnd@example.com").withPhone("98765432") .withTags("owesMoney", "friends").build(); - public static final ReadOnlyPerson CARL = new PersonBuilder().withName("Carl Kurz").withPhone("95352563") + public static final Person CARL = new PersonBuilder().withName("Carl Kurz").withPhone("95352563") .withEmail("heinz@example.com").withAddress("wall street").build(); - public static final ReadOnlyPerson DANIEL = new PersonBuilder().withName("Daniel Meier").withPhone("87652533") + public static final Person DANIEL = new PersonBuilder().withName("Daniel Meier").withPhone("87652533") .withEmail("cornelia@example.com").withAddress("10th street").build(); - public static final ReadOnlyPerson ELLE = new PersonBuilder().withName("Elle Meyer").withPhone("9482224") + public static final Person ELLE = new PersonBuilder().withName("Elle Meyer").withPhone("9482224") .withEmail("werner@example.com").withAddress("michegan ave").build(); - public static final ReadOnlyPerson FIONA = new PersonBuilder().withName("Fiona Kunz").withPhone("9482427") + public static final Person FIONA = new PersonBuilder().withName("Fiona Kunz").withPhone("9482427") .withEmail("lydia@example.com").withAddress("little tokyo").build(); - public static final ReadOnlyPerson GEORGE = new PersonBuilder().withName("George Best").withPhone("9482442") + public static final Person GEORGE = new PersonBuilder().withName("George Best").withPhone("9482442") .withEmail("anna@example.com").withAddress("4th street").build(); // Manually added - public static final ReadOnlyPerson HOON = new PersonBuilder().withName("Hoon Meier").withPhone("8482424") + public static final Person HOON = new PersonBuilder().withName("Hoon Meier").withPhone("8482424") .withEmail("stefan@example.com").withAddress("little india").build(); - public static final ReadOnlyPerson IDA = new PersonBuilder().withName("Ida Mueller").withPhone("8482131") + public static final Person IDA = new PersonBuilder().withName("Ida Mueller").withPhone("8482131") .withEmail("hans@example.com").withAddress("chicago ave").build(); // Manually added - Person's details found in {@code CommandTestUtil} - public static final ReadOnlyPerson AMY = new PersonBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_AMY) + public static final Person AMY = new PersonBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_AMY) .withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY).withTags(VALID_TAG_FRIEND).build(); - public static final ReadOnlyPerson BOB = new PersonBuilder().withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) + public static final Person BOB = new PersonBuilder().withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) .withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND) .build(); @@ -65,7 +65,7 @@ private TypicalPersons() {} // prevents instantiation */ public static AddressBook getTypicalAddressBook() { AddressBook ab = new AddressBook(); - for (ReadOnlyPerson person : getTypicalPersons()) { + for (Person person : getTypicalPersons()) { try { ab.addPerson(person); } catch (DuplicatePersonException e) { @@ -75,7 +75,7 @@ public static AddressBook getTypicalAddressBook() { return ab; } - public static List getTypicalPersons() { + public static List getTypicalPersons() { return new ArrayList<>(Arrays.asList(ALICE, BENSON, CARL, DANIEL, ELLE, FIONA, GEORGE)); } } diff --git a/src/test/java/seedu/address/ui/PersonCardTest.java b/src/test/java/seedu/address/ui/PersonCardTest.java index 5e376da85202..42f840faa3b4 100644 --- a/src/test/java/seedu/address/ui/PersonCardTest.java +++ b/src/test/java/seedu/address/ui/PersonCardTest.java @@ -9,7 +9,6 @@ import guitests.guihandles.PersonCardHandle; import seedu.address.model.person.Person; -import seedu.address.model.person.ReadOnlyPerson; import seedu.address.testutil.PersonBuilder; public class PersonCardTest extends GuiUnitTest { @@ -59,7 +58,7 @@ public void equals() { * Asserts that {@code personCard} displays the details of {@code expectedPerson} correctly and matches * {@code expectedId}. */ - private void assertCardDisplay(PersonCard personCard, ReadOnlyPerson expectedPerson, int expectedId) { + private void assertCardDisplay(PersonCard personCard, Person expectedPerson, int expectedId) { guiRobot.pauseForHuman(); PersonCardHandle personCardHandle = new PersonCardHandle(personCard.getRoot()); diff --git a/src/test/java/seedu/address/ui/PersonListPanelTest.java b/src/test/java/seedu/address/ui/PersonListPanelTest.java index b774c2a3320c..906ec2bebc03 100644 --- a/src/test/java/seedu/address/ui/PersonListPanelTest.java +++ b/src/test/java/seedu/address/ui/PersonListPanelTest.java @@ -15,10 +15,10 @@ import javafx.collections.FXCollections; import javafx.collections.ObservableList; import seedu.address.commons.events.ui.JumpToListRequestEvent; -import seedu.address.model.person.ReadOnlyPerson; +import seedu.address.model.person.Person; public class PersonListPanelTest extends GuiUnitTest { - private static final ObservableList TYPICAL_PERSONS = + private static final ObservableList TYPICAL_PERSONS = FXCollections.observableList(getTypicalPersons()); private static final JumpToListRequestEvent JUMP_TO_SECOND_EVENT = new JumpToListRequestEvent(INDEX_SECOND_PERSON); @@ -38,7 +38,7 @@ public void setUp() { public void display() { for (int i = 0; i < TYPICAL_PERSONS.size(); i++) { personListPanelHandle.navigateToCard(TYPICAL_PERSONS.get(i)); - ReadOnlyPerson expectedPerson = TYPICAL_PERSONS.get(i); + Person expectedPerson = TYPICAL_PERSONS.get(i); PersonCardHandle actualCard = personListPanelHandle.getPersonCardHandle(i); assertCardDisplaysPerson(expectedPerson, actualCard); diff --git a/src/test/java/seedu/address/ui/testutil/GuiTestAssert.java b/src/test/java/seedu/address/ui/testutil/GuiTestAssert.java index 965f200edbd3..d21cc2fb3739 100644 --- a/src/test/java/seedu/address/ui/testutil/GuiTestAssert.java +++ b/src/test/java/seedu/address/ui/testutil/GuiTestAssert.java @@ -8,7 +8,7 @@ import guitests.guihandles.PersonCardHandle; import guitests.guihandles.PersonListPanelHandle; import guitests.guihandles.ResultDisplayHandle; -import seedu.address.model.person.ReadOnlyPerson; +import seedu.address.model.person.Person; /** * A set of assertion methods useful for writing GUI tests. @@ -29,7 +29,7 @@ public static void assertCardEquals(PersonCardHandle expectedCard, PersonCardHan /** * Asserts that {@code actualCard} displays the details of {@code expectedPerson}. */ - public static void assertCardDisplaysPerson(ReadOnlyPerson expectedPerson, PersonCardHandle actualCard) { + public static void assertCardDisplaysPerson(Person expectedPerson, PersonCardHandle actualCard) { assertEquals(expectedPerson.getName().fullName, actualCard.getName()); assertEquals(expectedPerson.getPhone().value, actualCard.getPhone()); assertEquals(expectedPerson.getEmail().value, actualCard.getEmail()); @@ -42,7 +42,7 @@ public static void assertCardDisplaysPerson(ReadOnlyPerson expectedPerson, Perso * Asserts that the list in {@code personListPanelHandle} displays the details of {@code persons} correctly and * in the correct order. */ - public static void assertListMatching(PersonListPanelHandle personListPanelHandle, ReadOnlyPerson... persons) { + public static void assertListMatching(PersonListPanelHandle personListPanelHandle, Person... persons) { for (int i = 0; i < persons.length; i++) { assertCardDisplaysPerson(persons[i], personListPanelHandle.getPersonCardHandle(i)); } @@ -52,8 +52,8 @@ public static void assertListMatching(PersonListPanelHandle personListPanelHandl * Asserts that the list in {@code personListPanelHandle} displays the details of {@code persons} correctly and * in the correct order. */ - public static void assertListMatching(PersonListPanelHandle personListPanelHandle, List persons) { - assertListMatching(personListPanelHandle, persons.toArray(new ReadOnlyPerson[0])); + public static void assertListMatching(PersonListPanelHandle personListPanelHandle, List persons) { + assertListMatching(personListPanelHandle, persons.toArray(new Person[0])); } /** diff --git a/src/test/java/systemtests/AddCommandSystemTest.java b/src/test/java/systemtests/AddCommandSystemTest.java index c352a75f9d2c..3254b60154c4 100644 --- a/src/test/java/systemtests/AddCommandSystemTest.java +++ b/src/test/java/systemtests/AddCommandSystemTest.java @@ -45,8 +45,8 @@ import seedu.address.model.person.Address; import seedu.address.model.person.Email; import seedu.address.model.person.Name; +import seedu.address.model.person.Person; import seedu.address.model.person.Phone; -import seedu.address.model.person.ReadOnlyPerson; import seedu.address.model.person.exceptions.DuplicatePersonException; import seedu.address.model.tag.Tag; import seedu.address.testutil.PersonBuilder; @@ -63,7 +63,7 @@ public void add() throws Exception { /* Case: add a person without tags to a non-empty address book, command with leading spaces and trailing spaces * -> added */ - ReadOnlyPerson toAdd = AMY; + Person toAdd = AMY; String command = " " + AddCommand.COMMAND_WORD + " " + NAME_DESC_AMY + " " + PHONE_DESC_AMY + " " + EMAIL_DESC_AMY + " " + ADDRESS_DESC_AMY + " " + TAG_DESC_FRIEND + " "; assertCommandSuccess(command, toAdd); @@ -141,7 +141,7 @@ public void add() throws Exception { /* Case: add a duplicate person except with different tags -> rejected */ // "friends" is an existing tag used in the default model, see TypicalPersons#ALICE // This test will fail if a new tag that is not in the model is used, see the bug documented in - // AddressBook#addPerson(ReadOnlyPerson) + // AddressBook#addPerson(Person) command = PersonUtil.getAddCommand(HOON) + " " + PREFIX_TAG.getPrefix() + "friends"; assertCommandFailure(command, AddCommand.MESSAGE_DUPLICATE_PERSON); @@ -201,16 +201,16 @@ public void add() throws Exception { * {@code AddressBookSystemTest#assertApplicationDisplaysExpected(String, String, Model)}.
* @see AddressBookSystemTest#assertApplicationDisplaysExpected(String, String, Model) */ - private void assertCommandSuccess(ReadOnlyPerson toAdd) { + private void assertCommandSuccess(Person toAdd) { assertCommandSuccess(PersonUtil.getAddCommand(toAdd), toAdd); } /** - * Performs the same verification as {@code assertCommandSuccess(ReadOnlyPerson)}. Executes {@code command} + * Performs the same verification as {@code assertCommandSuccess(Person)}. Executes {@code command} * instead. - * @see AddCommandSystemTest#assertCommandSuccess(ReadOnlyPerson) + * @see AddCommandSystemTest#assertCommandSuccess(Person) */ - private void assertCommandSuccess(String command, ReadOnlyPerson toAdd) { + private void assertCommandSuccess(String command, Person toAdd) { Model expectedModel = getModel(); try { expectedModel.addPerson(toAdd); @@ -223,12 +223,12 @@ private void assertCommandSuccess(String command, ReadOnlyPerson toAdd) { } /** - * Performs the same verification as {@code assertCommandSuccess(String, ReadOnlyPerson)} except asserts that + * Performs the same verification as {@code assertCommandSuccess(String, Person)} except asserts that * the,
* 1. Result display box displays {@code expectedResultMessage}.
* 2. {@code Model}, {@code Storage} and {@code PersonListPanel} equal to the corresponding components in * {@code expectedModel}.
- * @see AddCommandSystemTest#assertCommandSuccess(String, ReadOnlyPerson) + * @see AddCommandSystemTest#assertCommandSuccess(String, Person) */ private void assertCommandSuccess(String command, Model expectedModel, String expectedResultMessage) { executeCommand(command); diff --git a/src/test/java/systemtests/DeleteCommandSystemTest.java b/src/test/java/systemtests/DeleteCommandSystemTest.java index 4a12f622d5a3..c0de78e4aba6 100644 --- a/src/test/java/systemtests/DeleteCommandSystemTest.java +++ b/src/test/java/systemtests/DeleteCommandSystemTest.java @@ -18,7 +18,7 @@ import seedu.address.logic.commands.RedoCommand; import seedu.address.logic.commands.UndoCommand; import seedu.address.model.Model; -import seedu.address.model.person.ReadOnlyPerson; +import seedu.address.model.person.Person; import seedu.address.model.person.exceptions.PersonNotFoundException; public class DeleteCommandSystemTest extends AddressBookSystemTest { @@ -33,7 +33,7 @@ public void delete() { /* Case: delete the first person in the list, command with leading spaces and trailing spaces -> deleted */ Model expectedModel = getModel(); String command = " " + DeleteCommand.COMMAND_WORD + " " + INDEX_FIRST_PERSON.getOneBased() + " "; - ReadOnlyPerson deletedPerson = removePerson(expectedModel, INDEX_FIRST_PERSON); + Person deletedPerson = removePerson(expectedModel, INDEX_FIRST_PERSON); String expectedResultMessage = String.format(MESSAGE_DELETE_PERSON_SUCCESS, deletedPerson); assertCommandSuccess(command, expectedModel, expectedResultMessage); @@ -113,11 +113,11 @@ public void delete() { } /** - * Removes the {@code ReadOnlyPerson} at the specified {@code index} in {@code model}'s address book. + * Removes the {@code Person} at the specified {@code index} in {@code model}'s address book. * @return the removed person */ - private ReadOnlyPerson removePerson(Model model, Index index) { - ReadOnlyPerson targetPerson = getPerson(model, index); + private Person removePerson(Model model, Index index) { + Person targetPerson = getPerson(model, index); try { model.deletePerson(targetPerson); } catch (PersonNotFoundException pnfe) { @@ -133,7 +133,7 @@ private ReadOnlyPerson removePerson(Model model, Index index) { */ private void assertCommandSuccess(Index toDelete) { Model expectedModel = getModel(); - ReadOnlyPerson deletedPerson = removePerson(expectedModel, toDelete); + Person deletedPerson = removePerson(expectedModel, toDelete); String expectedResultMessage = String.format(MESSAGE_DELETE_PERSON_SUCCESS, deletedPerson); assertCommandSuccess( diff --git a/src/test/java/systemtests/EditCommandSystemTest.java b/src/test/java/systemtests/EditCommandSystemTest.java index 71796d3fa19a..820933203dd9 100644 --- a/src/test/java/systemtests/EditCommandSystemTest.java +++ b/src/test/java/systemtests/EditCommandSystemTest.java @@ -43,7 +43,6 @@ import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; -import seedu.address.model.person.ReadOnlyPerson; import seedu.address.model.person.exceptions.DuplicatePersonException; import seedu.address.model.person.exceptions.PersonNotFoundException; import seedu.address.model.tag.Tag; @@ -88,7 +87,7 @@ public void edit() throws Exception { /* Case: edit some fields -> edited */ index = INDEX_FIRST_PERSON; command = EditCommand.COMMAND_WORD + " " + index.getOneBased() + TAG_DESC_FRIEND; - ReadOnlyPerson personToEdit = getModel().getFilteredPersonList().get(index.getZeroBased()); + Person personToEdit = getModel().getFilteredPersonList().get(index.getZeroBased()); editedPerson = new PersonBuilder(personToEdit).withTags(VALID_TAG_FRIEND).build(); assertCommandSuccess(command, index, editedPerson); @@ -190,12 +189,12 @@ public void edit() throws Exception { } /** - * Performs the same verification as {@code assertCommandSuccess(String, Index, ReadOnlyPerson, Index)} except that + * Performs the same verification as {@code assertCommandSuccess(String, Index, Person, Index)} except that * the browser url and selected card remain unchanged. * @param toEdit the index of the current model's filtered list - * @see EditCommandSystemTest#assertCommandSuccess(String, Index, ReadOnlyPerson, Index) + * @see EditCommandSystemTest#assertCommandSuccess(String, Index, Person, Index) */ - private void assertCommandSuccess(String command, Index toEdit, ReadOnlyPerson editedPerson) { + private void assertCommandSuccess(String command, Index toEdit, Person editedPerson) { assertCommandSuccess(command, toEdit, editedPerson, null); } @@ -207,7 +206,7 @@ private void assertCommandSuccess(String command, Index toEdit, ReadOnlyPerson e * @param toEdit the index of the current model's filtered list. * @see EditCommandSystemTest#assertCommandSuccess(String, Model, String, Index) */ - private void assertCommandSuccess(String command, Index toEdit, ReadOnlyPerson editedPerson, + private void assertCommandSuccess(String command, Index toEdit, Person editedPerson, Index expectedSelectedCardIndex) { Model expectedModel = getModel(); try { diff --git a/src/test/java/systemtests/ModelHelper.java b/src/test/java/systemtests/ModelHelper.java index 4d82b1a33058..b7950598d36b 100644 --- a/src/test/java/systemtests/ModelHelper.java +++ b/src/test/java/systemtests/ModelHelper.java @@ -6,19 +6,19 @@ import java.util.function.Predicate; import seedu.address.model.Model; -import seedu.address.model.person.ReadOnlyPerson; +import seedu.address.model.person.Person; /** * Contains helper methods to set up {@code Model} for testing. */ public class ModelHelper { - private static final Predicate PREDICATE_MATCHING_NO_PERSONS = unused -> false; + private static final Predicate PREDICATE_MATCHING_NO_PERSONS = unused -> false; /** * Updates {@code model}'s filtered list to display only {@code toDisplay}. */ - public static void setFilteredList(Model model, List toDisplay) { - Optional> predicate = + public static void setFilteredList(Model model, List toDisplay) { + Optional> predicate = toDisplay.stream().map(ModelHelper::getPredicateMatching).reduce(Predicate::or); model.updateFilteredPersonList(predicate.orElse(PREDICATE_MATCHING_NO_PERSONS)); } @@ -26,14 +26,14 @@ public static void setFilteredList(Model model, List toDisplay) /** * @see ModelHelper#setFilteredList(Model, List) */ - public static void setFilteredList(Model model, ReadOnlyPerson... toDisplay) { + public static void setFilteredList(Model model, Person... toDisplay) { setFilteredList(model, Arrays.asList(toDisplay)); } /** - * Returns a predicate that evaluates to true if this {@code ReadOnlyPerson} equals to {@code other}. + * Returns a predicate that evaluates to true if this {@code Person} equals to {@code other}. */ - private static Predicate getPredicateMatching(ReadOnlyPerson other) { + private static Predicate getPredicateMatching(Person other) { return person -> person.equals(other); } }