Skip to content
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

Fix code quality #306

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ public class AddCommandParser implements Parser<AddCommand> {

/**
* 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.");

Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ public class AddMaintainerCommandParser implements Parser<AddMaintainerCommand>
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.");

Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ public class AddStaffCommandParser implements Parser<AddStaffCommand> {

/**
* 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.");

Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ public class AddSupplierCommandParser implements Parser<AddSupplierCommand> {
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.");

Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,14 @@ public class DeleteCommandParser implements Parser<DeleteCommand> {

/**
* 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
Expand All @@ -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()));
Expand Down
16 changes: 6 additions & 10 deletions src/main/java/seedu/address/logic/parser/EditCommandParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ public class EditCommandParser implements Parser<EditCommand> {

/**
* 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);
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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) {
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public class EditMaintainerCommandParser implements Parser<EditMaintainerCommand

/**
* Parses the given {@code String} of arguments in the context of the EditMaintainerCommand
* and returns an EditMaintainerCommand object for execution. Parameter args cannot be null.
* @throws ParseException if the user input does not conform the expected format
* and returns an EditMaintainerCommand object for execution. Parameter {@code args} cannot be null.
* @throws ParseException If the user input does not conform to the expected format
*/
public EditMaintainerCommand parse(String args) throws ParseException {
requireNonNull(args);
Expand All @@ -42,9 +42,6 @@ public EditMaintainerCommand parse(String args) throws ParseException {
logger.log(Level.INFO, "Going to start parsing for edit maintainer command.");

String parsedArgs = ParserUtil.parseArg(args);
Name name;
String fieldArgs;
EditMaintainerDescriptor editMaintainerDescriptor;
ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(parsedArgs, PREFIX_NAME, PREFIX_FIELD);

// validates user command fields
Expand All @@ -62,8 +59,8 @@ public EditMaintainerCommand 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,
EditMaintainerCommand.MESSAGE_USAGE));

// maps fields to edit to their values
Expand All @@ -74,7 +71,7 @@ public EditMaintainerCommand parse(String args) throws ParseException {
fieldArgMultimap.verifyNoDuplicatePrefixesFor(PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS,
PREFIX_SKILL, PREFIX_COMMISSION);

editMaintainerDescriptor = editMaintainerDescription(fieldArgMultimap);
EditMaintainerDescriptor editMaintainerDescriptor = editMaintainerDescription(fieldArgMultimap);

boolean isNoFieldEdited = !editMaintainerDescriptor.isAnyFieldEdited();
if (isNoFieldEdited) {
Expand All @@ -93,7 +90,7 @@ public EditMaintainerCommand parse(String args) throws ParseException {
*
* @param fieldArgMultimap The mapping of field arguments into different specific fields.
* @return EditMaintainerDescriptor 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 EditMaintainerDescriptor editMaintainerDescription(
ArgumentMultimap fieldArgMultimap) throws ParseException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ public class EditStaffCommandParser implements Parser<EditStaffCommand> {

/**
* 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);
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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) {
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public class EditSupplierCommandParser implements Parser<EditSupplierCommand> {

/**
* 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);
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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) {
Expand All @@ -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 {
Expand Down
Loading
Loading