-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add basic functionalities for the ClearAllCommand #45
Add basic functionalities for the ClearAllCommand #45
Conversation
Todo (maybe enhancement later): Dislay that the list is empty after the clear command, i.e Showing a prompt saying the list is empty
Codecov Report
@@ Coverage Diff @@
## master #45 +/- ##
============================================
- Coverage 71.33% 70.65% -0.69%
Complexity 417 417
============================================
Files 74 75 +1
Lines 1284 1295 +11
Branches 131 132 +1
============================================
- Hits 916 915 -1
- Misses 334 345 +11
- Partials 34 35 +1
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me for the most part. I've left some comments as well. Thanks :^)
public static final String MESSAGE_USAGE = COMMAND_WORD | ||
+ ": Clears all entries from the address book.\n" | ||
+ "Example: " + COMMAND_WORD + " 1"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Address book to ForYourInterest
- " 1" is not needed, see user guide here for the format
case ClearAllCommand.COMMAND_WORD: | ||
return new ClearAllCommand(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Place this in alphabetical order if possible, in the same order as the import statements
/** | ||
* Clears every entry from this {@code AddressBook}. | ||
*/ | ||
public void clearAllPerson() { | ||
persons.clearAllPerson(); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we should change this @code AddressBook part, we might be able to refactor this all at once in the future
@Override | ||
public CommandResult execute(Model model) throws CommandException { | ||
List<Person> lastShownList = model.getFilteredPersonList(); | ||
|
||
if (lastShownList.size() == 0) { | ||
throw new CommandException(Messages.MESSAGE_EMPTY_LIST); | ||
} | ||
|
||
model.clearAllPerson(); | ||
return new CommandResult(MESSAGE_CLEAR_ALL_SUCCESS); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to get the unfiltered list.
Using the filtered list may lead to this scenario:
- There is data in the JSON file
- User filters with
find
command and uses some nonsense keyword - User gets 0 search results back
- lastShownList.size() == 0
- Exception thrown saying the JSON file is empty when it is not empty
Todo (maybe enhancement later): Dislay that the list is empty after the clear command,
i.e Showing a prompt saying the list is empty