From e79eb844a73bf941cc1a2f3858a382e7ed577cea Mon Sep 17 00:00:00 2001 From: blackpanther9229 Date: Thu, 24 Oct 2024 23:43:27 +0800 Subject: [PATCH] Style error fixed --- .../logic/parser/AddTagCommandParser.java | 105 +++++++++--------- 1 file changed, 51 insertions(+), 54 deletions(-) diff --git a/src/main/java/seedu/address/logic/parser/AddTagCommandParser.java b/src/main/java/seedu/address/logic/parser/AddTagCommandParser.java index aeee652fff2..10e87c67c50 100644 --- a/src/main/java/seedu/address/logic/parser/AddTagCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddTagCommandParser.java @@ -1,63 +1,60 @@ - package seedu.address.logic.parser; +package seedu.address.logic.parser; + +import static java.util.Objects.requireNonNull; +import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; +import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; + +import java.util.Collection; +import java.util.Collections; +import java.util.Optional; +import java.util.Set; + +import seedu.address.commons.core.index.Index; +import seedu.address.logic.commands.AddTagCommand; +import seedu.address.logic.parser.exceptions.ParseException; +import seedu.address.model.tag.Tag; + +/** + * Parses input arguments and creates a new AddTagCommand object + */ +public class AddTagCommandParser implements Parser { + /** + * Parses the given {@code String} of arguments in the context of the AddTagCommand + * and returns an AddTagCommand object for execution. + * @throws ParseException if the user input does not conform the expected format + */ + public AddTagCommand parse(String args) throws ParseException { + requireNonNull(args); + ArgumentMultimap argMultimap = + ArgumentTokenizer.tokenize(args, PREFIX_TAG); - import static java.util.Objects.requireNonNull; - import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; - import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; - import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; - import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; - import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; + Index index; + + try { + index = ParserUtil.parseIndex(argMultimap.getPreamble()); + } catch (ParseException pe) { + throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddTagCommand.MESSAGE_USAGE), pe); + } - import java.util.Collection; - import java.util.Collections; - import java.util.Optional; - import java.util.Set; + AddTagCommand.AddTagDescriptor addTagDescriptor = new AddTagCommand.AddTagDescriptor(); - import seedu.address.commons.core.index.Index; - import seedu.address.logic.commands.AddTagCommand; - import seedu.address.logic.parser.exceptions.ParseException; - import seedu.address.model.tag.Tag; + parseTagsToAdd(argMultimap.getAllValues(PREFIX_TAG)).ifPresent(addTagDescriptor::setTags); + + return new AddTagCommand(index, addTagDescriptor); + } /** - * Parses input arguments and creates a new AddTagCommand object + * Parses {@code Collection tags} into a {@code Set} if {@code tags} is non-empty. + * If {@code tags} contain only one element which is an empty string, it will be parsed into a + * {@code Set} containing zero tags. */ - public class AddTagCommandParser implements Parser { - /** - * Parses the given {@code String} of arguments in the context of the AddTagCommand - * and returns an AddTagCommand object for execution. - * @throws ParseException if the user input does not conform the expected format - */ - public AddTagCommand parse(String args) throws ParseException { - requireNonNull(args); - ArgumentMultimap argMultimap = - ArgumentTokenizer.tokenize(args, PREFIX_TAG); - - Index index; - - try { - index = ParserUtil.parseIndex(argMultimap.getPreamble()); - } catch (ParseException pe) { - throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddTagCommand.MESSAGE_USAGE), pe); - } - - AddTagCommand.AddTagDescriptor addTagDescriptor = new AddTagCommand.AddTagDescriptor(); - - parseTagsToAdd(argMultimap.getAllValues(PREFIX_TAG)).ifPresent(addTagDescriptor::setTags); - - return new AddTagCommand(index, addTagDescriptor); - } + private Optional> parseTagsToAdd(Collection tags) throws ParseException { + assert tags != null; - /** - * Parses {@code Collection tags} into a {@code Set} if {@code tags} is non-empty. - * If {@code tags} contain only one element which is an empty string, it will be parsed into a - * {@code Set} containing zero tags. - */ - private Optional> parseTagsToAdd(Collection tags) throws ParseException { - assert tags != null; - - if (tags.isEmpty()) { - return Optional.empty(); - } - Collection tagSet = tags.size() == 1 && tags.contains("") ? Collections.emptySet() : tags; - return Optional.of(ParserUtil.parseTags(tagSet)); + if (tags.isEmpty()) { + return Optional.empty(); } + Collection tagSet = tags.size() == 1 && tags.contains("") ? Collections.emptySet() : tags; + return Optional.of(ParserUtil.parseTags(tagSet)); } +}