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

Model: Add deleteTag(Tag) #591

Closed
wants to merge 1 commit into from

Conversation

yamgent
Copy link
Member

@yamgent yamgent commented Jul 28, 2017

Note: This is for the developer guide, we are not merging this.

@mention-bot
Copy link

@yamgent, thanks for your PR! By analyzing the history of the files in this pull request, we identified @damithc, @Zhiyuan-Amos and @yl-coder to be potential reviewers.

@yamgent yamgent closed this Jul 29, 2017
ReadOnlyPerson oldPerson = addressBook.getPersonList().get(i);

Person newPerson = new Person(oldPerson);
Set<Tag> newTags = newPerson.getTags();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getTags() returns an immutable tag set, which throws UnsupportedOperationException if modification is attempted.
making the subsequent newTags.remove(tag) method wrong.

Copy link

@nbriannl nbriannl Oct 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set<Tag> newTags = new HashSet<Tag>(newPerson.getTags()); would work in place of Line 91


Person newPerson = new Person(oldPerson);
Set<Tag> newTags = newPerson.getTags();
newTags.remove(tag);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reference, .remove(tag) on immutable newTags will throw Exception.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants