diff --git a/src/main/java/seedu/address/logic/parser/AddCommandParser.java b/src/main/java/seedu/address/logic/parser/AddCommandParser.java index b1a842cf0de..3deb3baae86 100644 --- a/src/main/java/seedu/address/logic/parser/AddCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddCommandParser.java @@ -35,11 +35,11 @@ public class AddCommandParser implements Parser { /** * Parses the given {@code String} of arguments in the context of the AddCommand - * and returns an AddCommand object for execution. Parameter args cannot be null. - * @throws ParseException if the user input does not conform the expected format + * and returns an AddCommand object for execution. Parameter {@code args} cannot be null. + * @throws ParseException If the user input does not conform to the expected format. */ public AddCommand parse(String args) throws ParseException { - assert (args != null) : "`argument` to pass for add command is null"; + assert (args != null) : "argument to pass for add command is null"; logger.log(Level.INFO, "Going to start parsing for add command."); @@ -70,7 +70,7 @@ public AddCommand parse(String args) throws ParseException { * Creates a person contact based on the argument multimap. * @param argMultimap Contains the mappings of values to the specific prefixes. * @return A person contact. - * @throws ParseException Thrown when invalid paramters are used. + * @throws ParseException If the user enters invalid paramters. */ private Person createPersonContact(ArgumentMultimap argMultimap) throws ParseException { try { diff --git a/src/main/java/seedu/address/logic/parser/AddMaintainerCommandParser.java b/src/main/java/seedu/address/logic/parser/AddMaintainerCommandParser.java index 1c64f1b3381..f72adc9c187 100644 --- a/src/main/java/seedu/address/logic/parser/AddMaintainerCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddMaintainerCommandParser.java @@ -39,11 +39,11 @@ public class AddMaintainerCommandParser implements Parser private final Logger logger = LogsCenter.getLogger(getClass()); /** * Parses the given {@code String} of arguments in the context of the AddStaffCommand - * and returns an AddCommand object for execution. Parameter args cannot be null. - * @throws ParseException if the user input does not conform the expected format + * and returns an AddCommand object for execution. Parameter {@code args} cannot be null. + * @throws ParseException If the user input does not conform to the expected format. */ public AddMaintainerCommand parse(String args) throws ParseException { - assert (args != null) : "`argument` to pass for add maintainer command is null"; + assert (args != null) : "argument to pass for add maintainer command is null"; logger.log(Level.INFO, "Going to start parsing for add maintainer command."); @@ -76,7 +76,7 @@ public AddMaintainerCommand parse(String args) throws ParseException { * Creates a maintainer contact based on the argument multimap. * @param argMultimap Contains the mappings of values to the specific prefixes. * @return A maintainer contact. - * @throws ParseException Thrown when invalid paramters are used. + * @throws ParseException If the user enters invalid paramters. */ private Maintainer createMaintainerContact(ArgumentMultimap argMultimap) throws ParseException { try { diff --git a/src/main/java/seedu/address/logic/parser/AddStaffCommandParser.java b/src/main/java/seedu/address/logic/parser/AddStaffCommandParser.java index 5a20c743b98..acce633ebdd 100644 --- a/src/main/java/seedu/address/logic/parser/AddStaffCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddStaffCommandParser.java @@ -39,11 +39,11 @@ public class AddStaffCommandParser implements Parser { /** * Parses the given {@code String} of arguments in the context of the AddStaffCommand - * and returns an AddCommand object for execution. Parameter args cannot be null. - * @throws ParseException if the user input does not conform the expected format + * and returns an AddCommand object for execution. Parameter {@code args} cannot be null. + * @throws ParseException If the user input does not conform to the expected format. */ public AddStaffCommand parse(String args) throws ParseException { - assert (args != null) : "`argument` to pass for add staff command is null"; + assert (args != null) : "argument to pass for add staff command is null"; logger.log(Level.INFO, "Going to start parsing for add staff command."); @@ -76,7 +76,7 @@ public AddStaffCommand parse(String args) throws ParseException { * Creates a staff contact based on the argument multimap. * @param argMultimap Contains the mappings of values to the specific prefixes. * @return A staff contact. - * @throws ParseException Thrown when invalid paramters are used. + * @throws ParseException If the user enters invalid paramters. */ private Staff createStaffContact(ArgumentMultimap argMultimap) throws ParseException { try { diff --git a/src/main/java/seedu/address/logic/parser/AddSupplierCommandParser.java b/src/main/java/seedu/address/logic/parser/AddSupplierCommandParser.java index b2da1883ac2..4ad518b824d 100644 --- a/src/main/java/seedu/address/logic/parser/AddSupplierCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddSupplierCommandParser.java @@ -38,11 +38,11 @@ public class AddSupplierCommandParser implements Parser { private final Logger logger = LogsCenter.getLogger(getClass()); /** * Parses the given {@code String} of arguments in the context of the AddStaffCommand - * and returns an AddCommand object for execution. Parameter args cannot be null. - * @throws ParseException if the user input does not conform the expected format + * and returns an AddCommand object for execution. Parameter {@code args} cannot be null. + * @throws ParseException If the user input does not conform to the expected format. */ public AddSupplierCommand parse(String args) throws ParseException { - assert (args != null) : "`argument` to pass for add supplier command is null"; + assert (args != null) : "argument to pass for add supplier command is null"; logger.log(Level.INFO, "Going to start parsing for supplier command."); @@ -73,7 +73,7 @@ public AddSupplierCommand parse(String args) throws ParseException { * Creates a supplier contact based on the argument multimap. * @param argMultimap Contains the mappings of values to the specific prefixes. * @return A supplier contact. - * @throws ParseException Thrown when invalid paramters are used. + * @throws ParseException If the user enters invalid paramters. */ private Supplier createSupplierContact(ArgumentMultimap argMultimap) throws ParseException { try { diff --git a/src/main/java/seedu/address/logic/parser/ArgumentMultimap.java b/src/main/java/seedu/address/logic/parser/ArgumentMultimap.java index 78cd2648c61..368a4c6de05 100644 --- a/src/main/java/seedu/address/logic/parser/ArgumentMultimap.java +++ b/src/main/java/seedu/address/logic/parser/ArgumentMultimap.java @@ -118,8 +118,8 @@ public boolean isPreambleEmpty() { } /** - * Gets all the prefixes - * @return an array of prefixes in the hashmap + * Gets all the prefixes. + * @return An array of prefixes in the hashmap. */ public Prefix[] getAllPrefixes() { return argMultimap.keySet().toArray(new Prefix[0]); @@ -144,7 +144,7 @@ public void verifyNoEmptyEntries() throws ParseException { } /** - * Returns a string implementation of Argument Multi Map + * Returns a string implementation of Argument Multi Map. */ @Override public String toString() { diff --git a/src/main/java/seedu/address/logic/parser/DeleteCommandParser.java b/src/main/java/seedu/address/logic/parser/DeleteCommandParser.java index 9c090e93ee6..263faf75d7f 100644 --- a/src/main/java/seedu/address/logic/parser/DeleteCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/DeleteCommandParser.java @@ -23,15 +23,14 @@ public class DeleteCommandParser implements Parser { /** * Parses the given {@code String} of arguments in the context of the DeleteCommand - * and returns a DeleteCommand object for execution. Parameter args cannot be null. - * @throws ParseException if the user input does not conform the expected format + * and returns a DeleteCommand object for execution. Parameter {@code args} cannot be null. + * @throws ParseException If the user input does not conform to the expected format. */ public DeleteCommand parse(String args) throws ParseException { - assert (args != null) : "`argument` to pass for delete command is null"; + assert (args != null) : "argument to pass for delete command is null"; logger.log(Level.INFO, "Going to start parsing for delete command."); - Name name; ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, PREFIX_NAME); // validates user command fields @@ -48,7 +47,7 @@ public DeleteCommand parse(String args) throws ParseException { } try { - name = ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).orElseThrow()); + Name name = ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).orElseThrow()); return new DeleteCommand(name); } catch (ParseException pe) { throw new ParseException(String.format(DeleteMessages.MESSAGE_DELETE_INVALID_PARAMETERS, pe.getMessage())); diff --git a/src/main/java/seedu/address/logic/parser/EditCommandParser.java b/src/main/java/seedu/address/logic/parser/EditCommandParser.java index 72a7aa3dfb9..d1c2fe6c433 100644 --- a/src/main/java/seedu/address/logic/parser/EditCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/EditCommandParser.java @@ -30,9 +30,8 @@ public class EditCommandParser implements Parser { /** * Parses the given {@code String} of arguments in the context of the EditCommand - * and returns an EditCommand object for execution. Parameter args cannot be null. - * - * @throws ParseException if the user input does not conform the expected format + * and returns an EditCommand object for execution. Parameter {@code args} cannot be null. + * @throws ParseException If the user input does not conform to the expected format. */ public EditCommand parse(String args) throws ParseException { requireNonNull(args); @@ -41,9 +40,6 @@ public EditCommand parse(String args) throws ParseException { logger.log(Level.INFO, "Going to start parsing for edit command."); String parsedArgs = ParserUtil.parseArg(args); - Name name; - String fieldArgs; - EditPersonDescriptor editPersonDescriptor; ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(parsedArgs, PREFIX_NAME, PREFIX_FIELD); // validates user command fields @@ -60,8 +56,8 @@ public EditCommand parse(String args) throws ParseException { } // maps user commands to name and field - name = ParserUtil.mapName(argMultimap, EditMessages.MESSAGE_EDIT_INVALID_NAME); - fieldArgs = ParserUtil.mapFields(argMultimap, String.format(MESSAGE_INVALID_COMMAND_FORMAT, + Name name = ParserUtil.mapName(argMultimap, EditMessages.MESSAGE_EDIT_INVALID_NAME); + String fieldArgs = ParserUtil.mapFields(argMultimap, String.format(MESSAGE_INVALID_COMMAND_FORMAT, EditCommand.MESSAGE_USAGE)); // maps fields to edit to their values @@ -70,7 +66,7 @@ public EditCommand parse(String args) throws ParseException { fieldArgMultimap.verifyNoDuplicatePrefixesFor(PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS); - editPersonDescriptor = editPersonDescription(fieldArgMultimap); + EditPersonDescriptor editPersonDescriptor = editPersonDescription(fieldArgMultimap); boolean isNoFieldEdited = !editPersonDescriptor.isAnyFieldEdited(); if (isNoFieldEdited) { @@ -88,7 +84,7 @@ public EditCommand parse(String args) throws ParseException { * * @param fieldArgMultimap The mapping of field arguments into different specific fields. * @return EditPersonDescriptor that contains the new values from the user. - * @throws ParseException Indicates the invalid format that users might have entered. + * @throws ParseException If the user enters invalid paramters. */ private EditPersonDescriptor editPersonDescription(ArgumentMultimap fieldArgMultimap) throws ParseException { try { diff --git a/src/main/java/seedu/address/logic/parser/EditMaintainerCommandParser.java b/src/main/java/seedu/address/logic/parser/EditMaintainerCommandParser.java index cc50d1e96c4..f2c57f6af5e 100644 --- a/src/main/java/seedu/address/logic/parser/EditMaintainerCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/EditMaintainerCommandParser.java @@ -32,8 +32,8 @@ public class EditMaintainerCommandParser implements Parser { /** * Parses the given {@code String} of arguments in the context of the EditStaffCommand - * and returns an EditStaffCommand object for execution. Parameter args cannot be null. - * - * @throws ParseException if the user input does not conform the expected format + * and returns an EditStaffCommand object for execution. Parameter {@code args} cannot be null. + * @throws ParseException If the user input does not conform to the expected format */ public EditStaffCommand parse(String args) throws ParseException { requireNonNull(args); @@ -43,9 +42,6 @@ public EditStaffCommand parse(String args) throws ParseException { logger.log(Level.INFO, "Going to start parsing for edit staff command."); String parsedArgs = ParserUtil.parseArg(args); - Name name; - String fieldArgs; - EditStaffDescriptor editStaffDescriptor; ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(parsedArgs, PREFIX_NAME, PREFIX_FIELD); // validates user command fields @@ -62,8 +58,8 @@ public EditStaffCommand parse(String args) throws ParseException { } // maps user commands to name and field - name = ParserUtil.mapName(argMultimap, EditMessages.MESSAGE_EDIT_INVALID_NAME); - fieldArgs = ParserUtil.mapFields(argMultimap, String.format(MESSAGE_INVALID_COMMAND_FORMAT, + Name name = ParserUtil.mapName(argMultimap, EditMessages.MESSAGE_EDIT_INVALID_NAME); + String fieldArgs = ParserUtil.mapFields(argMultimap, String.format(MESSAGE_INVALID_COMMAND_FORMAT, EditStaffCommand.MESSAGE_USAGE)); // maps fields to edit to their values @@ -74,7 +70,7 @@ public EditStaffCommand parse(String args) throws ParseException { fieldArgMultimap.verifyNoDuplicatePrefixesFor(PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_EMPLOYMENT, PREFIX_SALARY); - editStaffDescriptor = editStaffDescription(fieldArgMultimap); + EditStaffDescriptor editStaffDescriptor = editStaffDescription(fieldArgMultimap); boolean isNoFieldEdited = !editStaffDescriptor.isAnyFieldEdited(); if (isNoFieldEdited) { @@ -93,7 +89,7 @@ public EditStaffCommand parse(String args) throws ParseException { * * @param fieldArgMultimap The mapping of field arguments into different specific fields. * @return EditStaffDescriptor that contains the new values from the user. - * @throws ParseException Indicates the invalid format that users might have entered. + * @throws ParseException If the user enters invalid paramters. */ private EditStaffDescriptor editStaffDescription(ArgumentMultimap fieldArgMultimap) throws ParseException { try { diff --git a/src/main/java/seedu/address/logic/parser/EditSupplierCommandParser.java b/src/main/java/seedu/address/logic/parser/EditSupplierCommandParser.java index ec56483c7af..3bc2fb5a7b8 100644 --- a/src/main/java/seedu/address/logic/parser/EditSupplierCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/EditSupplierCommandParser.java @@ -32,8 +32,8 @@ public class EditSupplierCommandParser implements Parser { /** * Parses the given {@code String} of arguments in the context of the EditSupplierCommand - * and returns an EditSupplierCommand object for execution. Parameter args cannot be null. - * @throws ParseException if the user input does not conform the expected format + * and returns an EditSupplierCommand object for execution. Parameter {@code args} cannot be null. + * @throws ParseException If the user input does not conform to the expected format */ public EditSupplierCommand parse(String args) throws ParseException { requireNonNull(args); @@ -42,9 +42,6 @@ public EditSupplierCommand parse(String args) throws ParseException { logger.log(Level.INFO, "Going to start parsing for edit supplier command."); String parsedArgs = ParserUtil.parseArg(args); - Name name; - String fieldArgs; - EditSupplierDescriptor editSupplierDescriptor; ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(parsedArgs, PREFIX_NAME, PREFIX_FIELD); // validates user command fields @@ -62,8 +59,8 @@ public EditSupplierCommand parse(String args) throws ParseException { } // maps user commands to name and field - name = ParserUtil.mapName(argMultimap, EditMessages.MESSAGE_EDIT_INVALID_NAME); - fieldArgs = ParserUtil.mapFields(argMultimap, String.format(MESSAGE_INVALID_COMMAND_FORMAT, + Name name = ParserUtil.mapName(argMultimap, EditMessages.MESSAGE_EDIT_INVALID_NAME); + String fieldArgs = ParserUtil.mapFields(argMultimap, String.format(MESSAGE_INVALID_COMMAND_FORMAT, EditSupplierCommand.MESSAGE_USAGE)); // maps fields to edit to their values @@ -73,7 +70,7 @@ public EditSupplierCommand parse(String args) throws ParseException { fieldArgMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS); - editSupplierDescriptor = editSupplierDescription(fieldArgMultimap); + EditSupplierDescriptor editSupplierDescriptor = editSupplierDescription(fieldArgMultimap); boolean isNoFieldEdited = !editSupplierDescriptor.isAnyFieldEdited(); if (isNoFieldEdited) { @@ -92,7 +89,7 @@ public EditSupplierCommand parse(String args) throws ParseException { * * @param fieldArgMultimap The mapping of field arguments into different specific fields. * @return EditSupplierDescriptor that contains the new values from the user. - * @throws ParseException Indicates the invalid format that users might have entered. + * @throws ParseException If the user enters invalid paramters. */ private EditSupplierDescriptor editSupplierDescription(ArgumentMultimap fieldArgMultimap) throws ParseException { try { diff --git a/src/main/java/seedu/address/logic/parser/HelpCommandParser.java b/src/main/java/seedu/address/logic/parser/HelpCommandParser.java index 664c0bb5743..7afd3ccb08a 100644 --- a/src/main/java/seedu/address/logic/parser/HelpCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/HelpCommandParser.java @@ -19,15 +19,14 @@ public class HelpCommandParser implements Parser { /** * Parses the given {@code String} of arguments in the context of the HelpCommand - * and returns a HelpCommand object for execution. Parameter args cannot be null. - * - * @throws ParseException if the user input does not conform the expected format + * and returns a HelpCommand object for execution. Parameter {@code args} cannot be null. + * @throws ParseException If the user input does not conform to the expected format */ public HelpCommand parse(String args) throws ParseException { assert (args != null) : "argument to pass for help command is null"; logger.log(Level.INFO, "going to start parsing for help command."); - String commandType; + ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, PREFIX_HELP); // validates user command fields @@ -43,10 +42,10 @@ public HelpCommand parse(String args) throws ParseException { } try { - commandType = ParserUtil.parseHelp(argMultimap.getValue(PREFIX_HELP).orElseThrow()); + String commandType = ParserUtil.parseHelp(argMultimap.getValue(PREFIX_HELP).orElseThrow()); + return new HelpCommand(commandType); } catch (ParseException pe) { throw new ParseException(String.format(HelpMessages.MESSAGE_HELP_INVALID_PARAMETERS, pe.getMessage())); } - return new HelpCommand(commandType); } } diff --git a/src/main/java/seedu/address/logic/parser/NoteCommandParser.java b/src/main/java/seedu/address/logic/parser/NoteCommandParser.java index 934a75eabb3..1240182ca4f 100644 --- a/src/main/java/seedu/address/logic/parser/NoteCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/NoteCommandParser.java @@ -24,16 +24,14 @@ public class NoteCommandParser implements Parser { /** * Parses the given {@code String} of arguments in the context of the NoteCommand - * and returns a NoteCommand object for execution. Parameter args cannot be null. - * - * @throws ParseException if the user input does not conform the expected format. + * and returns a NoteCommand object for execution. Parameter {@code args} cannot be null. + * @throws ParseException If the user input does not conform to the expected format. */ public NoteCommand parse(String args) throws ParseException { assert (args != null) : "argument to pass for note command is null"; logger.log(Level.INFO, "Going to start parsing for note command."); - Name name; - Note note; + ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_NOTE, PREFIX_DEADLINE); // validates user command fields @@ -41,14 +39,15 @@ public NoteCommand parse(String args) throws ParseException { FAILED_TO_ADD_NOTE, PREFIX_NAME, PREFIX_NOTE, PREFIX_DEADLINE); ParserUtil.verifyNoMissingField(argMultimap, NoteCommand.MESSAGE_USAGE, "note", FAILED_TO_ADD_NOTE, PREFIX_NAME, PREFIX_NOTE); - boolean isContainingDeadlinePrefix = argMultimap.containsPrefix(PREFIX_DEADLINE); boolean isPreambleEmpty = argMultimap.isPreambleEmpty(); if (!isPreambleEmpty) { logger.log(Level.WARNING, "Parsing error while parsing for note command."); throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, NoteCommand.MESSAGE_USAGE)); } try { - name = ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get()); + Name name = ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get()); + boolean isContainingDeadlinePrefix = argMultimap.containsPrefix(PREFIX_DEADLINE); + Note note; if (!isContainingDeadlinePrefix) { note = ParserUtil.parseNote(argMultimap.getValue(PREFIX_NOTE).get()); } else { diff --git a/src/main/java/seedu/address/logic/parser/Parser.java b/src/main/java/seedu/address/logic/parser/Parser.java index d6551ad8e3f..da8ef8c811b 100644 --- a/src/main/java/seedu/address/logic/parser/Parser.java +++ b/src/main/java/seedu/address/logic/parser/Parser.java @@ -10,7 +10,7 @@ public interface Parser { /** * Parses {@code userInput} into a command and returns it. - * @throws ParseException if {@code userInput} does not conform the expected format + * @throws ParseException If {@code userInput} does not conform the expected format. */ T parse(String userInput) throws ParseException; } diff --git a/src/main/java/seedu/address/logic/parser/ParserUtil.java b/src/main/java/seedu/address/logic/parser/ParserUtil.java index e65a370ed6f..ce0384c8914 100644 --- a/src/main/java/seedu/address/logic/parser/ParserUtil.java +++ b/src/main/java/seedu/address/logic/parser/ParserUtil.java @@ -46,7 +46,7 @@ public class ParserUtil { /** * Parses {@code oneBasedIndex} into an {@code Index} and returns it. Leading and trailing whitespaces will be * trimmed. - * @throws ParseException if the specified index is invalid (not non-zero unsigned integer). + * @throws ParseException If the specified index is invalid (not non-zero unsigned integer). */ public static Index parseIndex(String oneBasedIndex) throws ParseException { String trimmedIndex = oneBasedIndex.trim(); @@ -59,8 +59,7 @@ public static Index parseIndex(String oneBasedIndex) throws ParseException { /** * Parses a {@code String name} into a {@code Name}. * Leading and trailing whitespaces will be trimmed. - * - * @throws ParseException if the given {@code name} is invalid. + * @throws ParseException If the given {@code name} is invalid. */ public static Name parseName(String name) throws ParseException { requireNonNull(name); @@ -75,8 +74,7 @@ public static Name parseName(String name) throws ParseException { /** * Parses a {@code String arg} into a {@code arg}. * Leading and trailing whitespaces will be trimmed. - * - * @throws ParseException if the given {@code name} is invalid. + * @throws ParseException If the given {@code name} is invalid. */ public static String parseArg(String arg) throws ParseException { requireNonNull(arg); @@ -87,8 +85,7 @@ public static String parseArg(String arg) throws ParseException { /** * Parses a {@code String phone} into a {@code Phone}. * Leading and trailing whitespaces will be trimmed. - * - * @throws ParseException if the given {@code phone} is invalid. + * @throws ParseException If the given {@code phone} is invalid. */ public static Phone parsePhone(String phone) throws ParseException { requireNonNull(phone); @@ -102,8 +99,7 @@ public static Phone parsePhone(String phone) throws ParseException { /** * Parses a {@code String address} into an {@code Address}. * Leading and trailing whitespaces will be trimmed. - * - * @throws ParseException if the given {@code address} is invalid. + * @throws ParseException If the given {@code address} is invalid. */ public static Address parseAddress(String address) throws ParseException { requireNonNull(address); @@ -117,8 +113,7 @@ public static Address parseAddress(String address) throws ParseException { /** * Parses a {@code String email} into an {@code Email}. * Leading and trailing whitespaces will be trimmed. - * - * @throws ParseException if the given {@code email} is invalid. + * @throws ParseException If the given {@code email} is invalid. */ public static Email parseEmail(String email) throws ParseException { requireNonNull(email); @@ -132,8 +127,7 @@ public static Email parseEmail(String email) throws ParseException { /** * Parses a {@code String employment} into an {@code Employment}. * Leading and trailing whitespaces will be trimmed. - * - * @throws ParseException if the given {@code employment} is invalid. + * @throws ParseException If the given {@code employment} is invalid. */ public static Employment parseEmployment(String employment) throws ParseException { requireNonNull(employment); @@ -147,8 +141,7 @@ public static Employment parseEmployment(String employment) throws ParseExceptio /** * Parses a {@code String salary} into an {@code Salary}. * Leading and trailing whitespaces will be trimmed. - * - * @throws ParseException if the given {@code salary} is invalid. + * @throws ParseException If the given {@code salary} is invalid. */ public static Salary parseSalary(String salary) throws ParseException { requireNonNull(salary); @@ -162,8 +155,7 @@ public static Salary parseSalary(String salary) throws ParseException { /** * Parses a {@code String product} into an {@code Product}. * Leading and trailing whitespaces will be trimmed. - * - * @throws ParseException if the given {@code product} is invalid. + * @throws ParseException If the given {@code product} is invalid. */ public static Product parseProduct(String product) throws ParseException { requireNonNull(product); @@ -178,7 +170,7 @@ public static Product parseProduct(String product) throws ParseException { * Parses a {@code String price} into an {@code Price}. * Leading and trailing whitespaces will be trimmed. * - * @throws ParseException if the given {@code price} is invalid. + * @throws ParseException If the given {@code price} is invalid. */ public static Price parsePrice(String price) throws ParseException { requireNonNull(price); @@ -192,8 +184,7 @@ public static Price parsePrice(String price) throws ParseException { /** * Parses a {@code String skill} into an {@code Skill}. * Leading and trailing whitespaces will be trimmed. - * - * @throws ParseException if the given {@code skill} is invalid. + * @throws ParseException If the given {@code skill} is invalid. */ public static Skill parseSkill(String skill) throws ParseException { requireNonNull(skill); @@ -207,8 +198,7 @@ public static Skill parseSkill(String skill) throws ParseException { /** * Parses a {@code String commission} into an {@code Commission}. * Leading and trailing whitespaces will be trimmed. - * - * @throws ParseException if the given {@code commission} is invalid. + * @throws ParseException If the given {@code commission} is invalid. */ public static Commission parseCommission(String commission) throws ParseException { requireNonNull(commission); @@ -222,8 +212,7 @@ public static Commission parseCommission(String commission) throws ParseExceptio /** * Parses a {@code String tag} into a {@code Tag}. * Leading and trailing whitespaces will be trimmed. - * - * @throws ParseException if the given {@code tag} is invalid. + * @throws ParseException If the given {@code tag} is invalid. */ public static Tag parseTag(String tag) throws ParseException { requireNonNull(tag); @@ -259,8 +248,7 @@ public static String parseField(String args) throws ParseException { /** * Parses a {@code String note} into a {@code Note}. * Leading and trailing whitespaces will be trimmed. - * - * @throws ParseException if the given {@code note} is invalid. + * @throws ParseException If the given {@code note} is invalid. */ public static Note parseNote(String note) throws ParseException { requireNonNull(note); @@ -277,8 +265,7 @@ public static Note parseNote(String note) throws ParseException { /** * Parses a {@code String note} into a {@code Note}. * Leading and trailing whitespaces will be trimmed. - * - * @throws ParseException if the given {@code note} is invalid. + * @throws ParseException If the given {@code note} is invalid. */ public static Rating parseRating(String rating) throws ParseException { requireNonNull(rating); @@ -292,8 +279,7 @@ public static Rating parseRating(String rating) throws ParseException { /** * Parses a {@code String note} into a {@code Note}. * Leading and trailing whitespaces will be trimmed. - * - * @throws ParseException if the given {@code note} is invalid. + * @throws ParseException If the given {@code note} is invalid. */ public static DeadlineNote parseDeadlineNote(String note, String deadline) throws ParseException { requireNonNull(note, deadline); @@ -312,8 +298,7 @@ public static DeadlineNote parseDeadlineNote(String note, String deadline) throw /** * Parses a {@code String note}. * Leading and trailing whitespaces will be trimmed. - * - * @throws ParseException if the given {@code commandType} is invalid. + * @throws ParseException If the given {@code commandType} is invalid. */ public static String parseHelp(String commandType) throws ParseException { @@ -328,8 +313,7 @@ public static String parseHelp(String commandType) throws ParseException { /** * Parses a {@code String sort field}. * Leading "; " and trailing " : " will be trimmed - * - * @throws ParseException if the given {@code commandType} is invalid. + * @throws ParseException If the given {@code commandType} is invalid. */ public static String parseSortField(String sortField) throws ParseException { @@ -381,7 +365,7 @@ public static boolean arePrefixesPresent(ArgumentMultimap argumentMultimap, Pref * @param argMultimap Object that contains mapping of prefix to value. * @param message Error message to throw if parse exception. * @return Returns object representing name. - * @throws ParseException Thrown when command is in invalid format. + * @throws ParseException If command is in invalid format. */ public static Name mapName(ArgumentMultimap argMultimap, String message) throws ParseException { try { @@ -396,7 +380,7 @@ public static Name mapName(ArgumentMultimap argMultimap, String message) throws * @param argMultimap Object that contains mapping of prefix to value. * @param message Error message to throw if parse exception. * @return Returns object representing the respective fields. - * @throws ParseException Thrown when command is in invalid format. + * @throws ParseException If command is in invalid format. */ public static String mapFields(ArgumentMultimap argMultimap, String message) throws ParseException { try { @@ -413,7 +397,7 @@ public static String mapFields(ArgumentMultimap argMultimap, String message) thr * @param commandType Command Type. * @param headerMessage Header of error messages. * @param prefixes Required prefixes in the command. - * @throws ParseException Thrown when there are invalid prefixes. + * @throws ParseException If there are invalid prefixes. */ public static void verifyNoUnknownPrefix(String args, String message, String commandType, String headerMessage, Prefix... prefixes) @@ -435,7 +419,7 @@ public static void verifyNoUnknownPrefix(String args, String message, String com * @param commandType Command Type. * @param headerMessage Header of error messages. * @param prefixes Required prefixes in the command. - * @throws ParseException Thrown when there are missing prefixes. + * @throws ParseException If there are missing prefixes. */ public static void verifyNoMissingField(ArgumentMultimap argMultimap, String message, String commandType, String headerMessage, Prefix... prefixes) throws diff --git a/src/main/java/seedu/address/logic/parser/PinCommandParser.java b/src/main/java/seedu/address/logic/parser/PinCommandParser.java index 0e3f1347193..25e08fae762 100644 --- a/src/main/java/seedu/address/logic/parser/PinCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/PinCommandParser.java @@ -4,6 +4,10 @@ import static seedu.address.logic.messages.Messages.FAILED_TO_PIN; import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; +import java.util.logging.Level; +import java.util.logging.Logger; + +import seedu.address.commons.core.LogsCenter; import seedu.address.logic.commands.PinCommand; import seedu.address.logic.messages.PinMessages; import seedu.address.logic.parser.exceptions.ParseException; @@ -13,17 +17,19 @@ * Parses input arguments and creates a new PinCommand object */ public class PinCommandParser implements Parser { + private final Logger logger = LogsCenter.getLogger(getClass()); /** * Parses the given {@code String} of arguments in the context of the PinCommand - * and returns an PinCommand object for execution. Parameter args cannot be null. - * @throws ParseException if the user input does not conform the expected format + * and returns a PinCommand object for execution. Parameter {@code args} cannot be null. + * @throws ParseException If the user input does not conform to the expected format. */ public PinCommand parse(String args) throws ParseException { requireNonNull(args); assert (args != null) : "argument to pass for pin command is null"; - Name name; + logger.log(Level.INFO, "Going to start parsing for pin command."); + ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, PREFIX_NAME); @@ -35,7 +41,7 @@ public PinCommand parse(String args) throws ParseException { FAILED_TO_PIN, PREFIX_NAME); - name = ParserUtil.mapName(argMultimap, PinMessages.MESSAGE_PIN_INVALID_NAME); + Name name = ParserUtil.mapName(argMultimap, PinMessages.MESSAGE_PIN_INVALID_NAME); return new PinCommand(name); } diff --git a/src/main/java/seedu/address/logic/parser/RateCommandParser.java b/src/main/java/seedu/address/logic/parser/RateCommandParser.java index e304e9a00e2..937543cc916 100644 --- a/src/main/java/seedu/address/logic/parser/RateCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/RateCommandParser.java @@ -26,17 +26,15 @@ public class RateCommandParser implements Parser { /** * Parses the given {@code String} of arguments in the context of the RateCommand - * and returns a RateCommand object for execution. Parameter args cannot be null. - * - * @throws ParseException if the user input does not conform the expected format + * and returns a RateCommand object for execution. Parameter {@code args} cannot be null. + * @throws ParseException If the user input does not conform to the expected format. */ public RateCommand parse(String args) throws ParseException { assert (args != null) : "argument to pass for rate command is null"; logger.log(Level.INFO, "Going to start parsing for rate command."); + ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_RATING); - Name name; - Rating rating; // validates user command fields ParserUtil.verifyNoUnknownPrefix(args, RateCommand.MESSAGE_USAGE, "rate", @@ -48,8 +46,8 @@ public RateCommand parse(String args) throws ParseException { argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS); try { - name = ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).orElseThrow()); - rating = ParserUtil.parseRating(argMultimap.getValue(PREFIX_RATING).orElseThrow()); + Name name = ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).orElseThrow()); + Rating rating = ParserUtil.parseRating(argMultimap.getValue(PREFIX_RATING).orElseThrow()); return new RateCommand(name, rating); } catch (ParseException pe) { throw new ParseException(String.format(RateMessages.MESSAGE_RATE_INVALID_PARAMETERS, pe.getMessage())); diff --git a/src/main/java/seedu/address/logic/parser/SearchCommandParser.java b/src/main/java/seedu/address/logic/parser/SearchCommandParser.java index 2fa67edfd78..e0f38152d5f 100644 --- a/src/main/java/seedu/address/logic/parser/SearchCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/SearchCommandParser.java @@ -17,8 +17,8 @@ public class SearchCommandParser implements Parser { /** * Parses the given {@code String} of arguments in the context of the SearchCommand - * and returns a SearchCommand object for execution. Parameter args cannot be null. - * @throws ParseException if the user input does not conform the expected format + * and returns a SearchCommand object for execution. Parameter {@code args} cannot be null. + * @throws ParseException If the user input does not conform to the expected format. */ public SearchCommand parse(String args) throws ParseException { assert (args != null) : "argument to pass for search command is null"; diff --git a/src/main/java/seedu/address/logic/parser/SortCommandParser.java b/src/main/java/seedu/address/logic/parser/SortCommandParser.java index 9268c5bd24e..831f57cf18b 100644 --- a/src/main/java/seedu/address/logic/parser/SortCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/SortCommandParser.java @@ -16,14 +16,13 @@ public class SortCommandParser implements Parser { /** * Parses the given {@code String} of arguments in the context of the SortCommand - * and returns an SortCommand object for execution. Parameter args cannot be null. - * @throws ParseException if the user input does not conform the expected format + * and returns a SortCommand object for execution. Parameter {@code args} cannot be null. + * @throws ParseException If the user input does not conform to the expected format. */ public SortCommand parse(String args) throws ParseException { requireNonNull(args); assert (args != null) : "argument to pass for sort command is null"; - Prefix prefix; ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, PREFIX_FIELD); // validates user command fields @@ -33,7 +32,7 @@ public SortCommand parse(String args) throws ParseException { FAILED_TO_SORT, PREFIX_FIELD); argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_FIELD); - prefix = mapName(argMultimap); + Prefix prefix = mapName(argMultimap); return new SortCommand(prefix); } @@ -42,7 +41,7 @@ public SortCommand parse(String args) throws ParseException { * Returns prefix value * @param argMultimap Object that contains mapping of field to prefix. * @return Returns object representing prefix - * @throws ParseException Thrown when command is in invalid format. + * @throws ParseException If the user enters invalid paramters. */ public Prefix mapName(ArgumentMultimap argMultimap) throws ParseException { try { diff --git a/src/main/java/seedu/address/logic/parser/UnpinCommandParser.java b/src/main/java/seedu/address/logic/parser/UnpinCommandParser.java index 4f1360ac93c..2667b356b10 100644 --- a/src/main/java/seedu/address/logic/parser/UnpinCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/UnpinCommandParser.java @@ -4,6 +4,10 @@ import static seedu.address.logic.messages.Messages.FAILED_TO_UNPIN; import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; +import java.util.logging.Level; +import java.util.logging.Logger; + +import seedu.address.commons.core.LogsCenter; import seedu.address.logic.commands.UnpinCommand; import seedu.address.logic.messages.UnpinMessages; import seedu.address.logic.parser.exceptions.ParseException; @@ -13,17 +17,18 @@ * Parses input arguments and creates a new UnpinCommand object */ public class UnpinCommandParser implements Parser { - + private final Logger logger = LogsCenter.getLogger(getClass()); /** * Parses the given {@code String} of arguments in the context of the UnpinCommand - * and returns an UnpinCommand object for execution. Parameter args cannot be null. - * @throws ParseException if the user input does not conform the expected format + * and returns an UnpinCommand object for execution. Parameter {@code args} cannot be null. + * @throws ParseException If the user input does not conform to he expected format. */ public UnpinCommand parse(String args) throws ParseException { requireNonNull(args); assert (args != null) : "argument to pass for unpin command is null"; - Name name; + logger.log(Level.INFO, "Going to start parsing for unpin command."); + ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, PREFIX_NAME); @@ -33,7 +38,7 @@ public UnpinCommand parse(String args) throws ParseException { ParserUtil.verifyNoMissingField(argMultimap, UnpinCommand.MESSAGE_USAGE, "unpin", FAILED_TO_UNPIN, PREFIX_NAME); - name = ParserUtil.mapName(argMultimap, UnpinMessages.MESSAGE_UNPIN_INVALID_NAME); + Name name = ParserUtil.mapName(argMultimap, UnpinMessages.MESSAGE_UNPIN_INVALID_NAME); return new UnpinCommand(name); }