src/main/java/seedu/insurancepal/logic/parser/EditCommandParser.java
/**
     * Parses the given {@code String} of arguments in the context of the EditCommand
     * and returns an EditCommand object for execution.
     * @throws ParseException if the user input does not conform the expected format
     */
Parses the given  String of arguments in the context of the EditCommand
and returns an EditCommand object for execution.
@throws ParseException if the user input does not conform the expected format
Parses the given String of arguments in the context of the EditCommand and returns an EditCommand object for execution . @throws ParseException if the user input does not conform the expected format
public EditCommand parse(String args) throws ParseException {
        requireNonNull(args);
        ArgumentMultimap argMultimap =
                ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_REVENUE,
                        PREFIX_ADDRESS, PREFIX_TAG, PREFIX_INSURANCE, PREFIX_NOTE);
        Index index;
        try {
            index = ParserUtil.parseIndex(argMultimap.getPreamble());
        } catch (ParseException pe) {
            throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, EditCommand.MESSAGE_USAGE), pe);
        }
        EditPersonDescriptor editPersonDescriptor = new EditPersonDescriptor();
        if (argMultimap.getValue(PREFIX_NAME).isPresent()) {
            editPersonDescriptor.setName(ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get()));
        }
        if (argMultimap.getValue(PREFIX_PHONE).isPresent()) {
            editPersonDescriptor.setPhone(ParserUtil.parsePhone(argMultimap.getValue(PREFIX_PHONE).get()));
        }
        if (argMultimap.getValue(PREFIX_EMAIL).isPresent()) {
            editPersonDescriptor.setEmail(ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL).get()));
        }
        if (argMultimap.getValue(PREFIX_REVENUE).isPresent()) {
            Revenue revenue = ParserUtil.parseRevenue(argMultimap.getValue(PREFIX_REVENUE).get());
            checkForNegativeRevenue(editPersonDescriptor, revenue);
            checkForOverflowRevenue(editPersonDescriptor, revenue);
        }
        if (argMultimap.getValue(PREFIX_ADDRESS).isPresent()) {
            editPersonDescriptor.setAddress(ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS).get()));
        }
        parseTagsForEdit(argMultimap.getAllValues(PREFIX_TAG)).ifPresent(editPersonDescriptor::setTags);
        parseInsurancesForEdit(argMultimap.getAllValues(PREFIX_INSURANCE))
                .ifPresent(editPersonDescriptor::setInsurances);
        if (argMultimap.getValue(PREFIX_NOTE).isPresent()) {
            editPersonDescriptor.setNote(ParserUtil.parseNote(argMultimap.getValue(PREFIX_NOTE).get()));
        }
        if (!editPersonDescriptor.isAnyFieldEdited()) {
            throw new ParseException(EditCommand.MESSAGE_NOT_EDITED);
        }
        return new EditCommand(index, editPersonDescriptor);
    }
public EditCommand parse ( String args ) throws ParseException { requireNonNull ( args ) ; ArgumentMultimap argMultimap = ArgumentTokenizer . tokenize ( args , PREFIX_NAME , PREFIX_PHONE , PREFIX_EMAIL , PREFIX_REVENUE , PREFIX_ADDRESS , PREFIX_TAG , PREFIX_INSURANCE , PREFIX_NOTE ) ; Index index ; try { index = ParserUtil . parseIndex ( argMultimap . getPreamble ( ) ) ; } catch ( ParseException pe ) { throw new ParseException ( String . format ( MESSAGE_INVALID_COMMAND_FORMAT , EditCommand . MESSAGE_USAGE ) , pe ) ; } EditPersonDescriptor editPersonDescriptor = new EditPersonDescriptor ( ) ; if ( argMultimap . getValue ( PREFIX_NAME ) . isPresent ( ) ) { editPersonDescriptor . setName ( ParserUtil . parseName ( argMultimap . getValue ( PREFIX_NAME ) . get ( ) ) ) ; } if ( argMultimap . getValue ( PREFIX_PHONE ) . isPresent ( ) ) { editPersonDescriptor . setPhone ( ParserUtil . parsePhone ( argMultimap . getValue ( PREFIX_PHONE ) . get ( ) ) ) ; } if ( argMultimap . getValue ( PREFIX_EMAIL ) . isPresent ( ) ) { editPersonDescriptor . setEmail ( ParserUtil . parseEmail ( argMultimap . getValue ( PREFIX_EMAIL ) . get ( ) ) ) ; } if ( argMultimap . getValue ( PREFIX_REVENUE ) . isPresent ( ) ) { Revenue revenue = ParserUtil . parseRevenue ( argMultimap . getValue ( PREFIX_REVENUE ) . get ( ) ) ; checkForNegativeRevenue ( editPersonDescriptor , revenue ) ; checkForOverflowRevenue ( editPersonDescriptor , revenue ) ; } if ( argMultimap . getValue ( PREFIX_ADDRESS ) . isPresent ( ) ) { editPersonDescriptor . setAddress ( ParserUtil . parseAddress ( argMultimap . getValue ( PREFIX_ADDRESS ) . get ( ) ) ) ; } parseTagsForEdit ( argMultimap . getAllValues ( PREFIX_TAG ) ) . ifPresent ( editPersonDescriptor :: setTags ) ; parseInsurancesForEdit ( argMultimap . getAllValues ( PREFIX_INSURANCE ) ) . ifPresent ( editPersonDescriptor :: setInsurances ) ; if ( argMultimap . getValue ( PREFIX_NOTE ) . isPresent ( ) ) { editPersonDescriptor . setNote ( ParserUtil . parseNote ( argMultimap . getValue ( PREFIX_NOTE ) . get ( ) ) ) ; } if ( ! editPersonDescriptor . isAnyFieldEdited ( ) ) { throw new ParseException ( EditCommand . MESSAGE_NOT_EDITED ) ; } return new EditCommand ( index , editPersonDescriptor ) ; }
Parses the given {@code String} of arguments in the context of the EditCommand
 and returns an EditCommand object for execution.
Parses the given { @code String } of arguments in the context of the EditCommand and returns an EditCommand object for execution .