forked from nusCS2113-AY1819S1/addressbook-level4
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
Implemented AddMilestoneCommandParser #48
Closed
Closed
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
86a4cdc
Updated UG and DG for addTask + addDeadline
chel-seyy 1a9c0eb
Merge pull request #1 from chelseyong/master (UG & DG)
chel-seyy c39cf42
Minor modification in DG
chel-seyy 0ebad8c
Merge branch 'master' of https://github.com/CS2113-AY1819S1-W13-3/main
JeremyAw 532f2dd
Merge branch 'master' of https://github.com/CS2113-AY1819S1-W13-3/main
JeremyAw b36206f
Merge branch 'master' of https://github.com/CS2113-AY1819S1-W13-3/main
JeremyAw 50f19f4
Implemented AddMilestoneCommandParser for the milestone feature
JeremyAw 0be14c5
Updated LogicManager to accomodate AddMilestoneCommand
JeremyAw b213c04
Merge branch 'master' of https://github.com/CS2113-AY1819S1-W13-3/mai…
JeremyAw fe913e4
Corrected Jeremy's githubId and authorName
JeremyAw 3ad7de8
Revert "Corrected Jeremy's githubId and authorName"
JeremyAw 5768e4e
Changed Milestone class to no longer be a subclass of the Task class
JeremyAw ee51416
Edited Task constructor to include a Set to store the add milestones
JeremyAw b7500a1
Improved AddMilestoneCommand to be able to select a task from the cur…
JeremyAw b4e5a0b
Commented out previously used code for addMilestone
JeremyAw 18bb440
Fixed minor checkstyle issues
JeremyAw File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/main/java/seedu/address/logic/parser/AddMilestoneCommandParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package seedu.address.logic.parser; | ||
|
||
import seedu.address.logic.commands.AddMilestoneCommand; | ||
import seedu.address.logic.parser.exceptions.ParseException; | ||
import seedu.address.model.task.Milestone; | ||
|
||
import java.util.stream.Stream; | ||
|
||
import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_TITLE; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_MILESTONE; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_RANK; | ||
|
||
//@@author JeremyInElysium | ||
/** | ||
* Parses input arguments and creates a new AddMilestoneCommand object | ||
*/ | ||
public class AddMilestoneCommandParser implements Parser<AddMilestoneCommand> { | ||
|
||
/** | ||
* Returns true if none of the prefixes contain empty {@code Optional} values in the given | ||
* {@code ArgumentMultiMap}. | ||
*/ | ||
private static boolean arePrefixesPresent(ArgumentMultimap argumentMultimap, Prefix... prefixes) { | ||
return Stream.of(prefixes).allMatch(prefix -> argumentMultimap.getValue(prefix).isPresent()); | ||
} | ||
|
||
@Override | ||
public AddMilestoneCommand parse(String userInput) throws ParseException { | ||
ArgumentMultimap argMultimap = | ||
ArgumentTokenizer.tokenize(userInput, PREFIX_TITLE, PREFIX_MILESTONE, PREFIX_RANK); | ||
|
||
if(!arePrefixesPresent(argMultimap, PREFIX_TITLE, PREFIX_MILESTONE, PREFIX_RANK) | ||
|| !argMultimap.getPreamble().isEmpty()) { | ||
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddMilestoneCommand.MESSAGE_USAGE)); | ||
} | ||
|
||
String title = ParserUtil.parseTitle(argMultimap.getValue(PREFIX_TITLE).get()); | ||
String milestoneDescription = ParserUtil.parseMilestoneDescription(argMultimap.getValue(PREFIX_MILESTONE).get()); | ||
String rank = ParserUtil.parseRank(argMultimap.getValue(PREFIX_RANK).get()); | ||
|
||
Milestone milestone = new Milestone(title, milestoneDescription, rank); | ||
|
||
return new AddMilestoneCommand(milestone); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
More intuitive to have rank as a int? U may consider parsingRank as a string then converting it into an integer.