src/main/java/seedu/address/logic/parser/AddCommandParser.java
public AddCommand parse(String args) throws ParseException {
        ArgumentMultimap argMultimap =
                ArgumentTokenizer.tokenize(args, PREFIX_TRACKING_NUMBER, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL,
                        PREFIX_ADDRESS, PREFIX_DELIVERY_DATE, PREFIX_STATUS, PREFIX_TAG);
        if (!arePrefixesPresent(argMultimap, PREFIX_TRACKING_NUMBER, PREFIX_NAME, PREFIX_ADDRESS,
                PREFIX_DELIVERY_DATE)) {
            throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE));
        }

        try {
            TrackingNumber trackingNumber = ParserUtil.parseTrackingNumber(argMultimap
                    .getValue(PREFIX_TRACKING_NUMBER)).get();
            Name name = ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME)).get();
            Address address = ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS)).get();
            DeliveryDate deliveryDate = ParserUtil.parseDeliveryDate(argMultimap.getValue(PREFIX_DELIVERY_DATE)).get();
            Set<Tag> tagList = ParserUtil.parseTags(argMultimap.getAllValues(PREFIX_TAG));
            Optional<Email> emailOptional = ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL));
            Optional<Status> statusOptional = ParserUtil.parseStatus(argMultimap.getValue(PREFIX_STATUS));
            Optional<Phone> phoneOptional = ParserUtil.parsePhone(argMultimap.getValue(PREFIX_PHONE));

            Email email;
            Status status;
            Phone phone;

            if (emailOptional.isPresent()) {
                email = emailOptional.get();
            } else {
                email = new Email();
            }

            if (statusOptional.isPresent()) {
                status = statusOptional.get();
            } else {
                status = Status.PENDING;
            }

            if (phoneOptional.isPresent()) {
                phone = phoneOptional.get();
            } else {
                phone = new Phone();
            }

            ReadOnlyParcel parcel = new Parcel(trackingNumber, name, phone, email, address, deliveryDate, status,
                    tagList);

            return new AddCommand(parcel);
        } catch (IllegalValueException ive) {
            throw new ParseException(ive.getMessage(), ive);
        }
    }
/**
     * Parses the given {@code String} of arguments in the context of the AddCommand
     * and returns an AddCommand 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 AddCommand
and returns an AddCommand 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 AddCommand and returns an AddCommand object for execution . @throws ParseException if the user input does not conform the expected format
public AddCommand parse(String args) throws ParseException {
        ArgumentMultimap argMultimap =
                ArgumentTokenizer.tokenize(args, PREFIX_TRACKING_NUMBER, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL,
                        PREFIX_ADDRESS, PREFIX_DELIVERY_DATE, PREFIX_STATUS, PREFIX_TAG);
        if (!arePrefixesPresent(argMultimap, PREFIX_TRACKING_NUMBER, PREFIX_NAME, PREFIX_ADDRESS,
                PREFIX_DELIVERY_DATE)) {
            throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE));
        }
        try {
            TrackingNumber trackingNumber = ParserUtil.parseTrackingNumber(argMultimap
                    .getValue(PREFIX_TRACKING_NUMBER)).get();
            Name name = ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME)).get();
            Address address = ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS)).get();
            DeliveryDate deliveryDate = ParserUtil.parseDeliveryDate(argMultimap.getValue(PREFIX_DELIVERY_DATE)).get();
            Set<Tag> tagList = ParserUtil.parseTags(argMultimap.getAllValues(PREFIX_TAG));
            Optional<Email> emailOptional = ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL));
            Optional<Status> statusOptional = ParserUtil.parseStatus(argMultimap.getValue(PREFIX_STATUS));
            Optional<Phone> phoneOptional = ParserUtil.parsePhone(argMultimap.getValue(PREFIX_PHONE));
            Email email;
            Status status;
            Phone phone;
            if (emailOptional.isPresent()) {
                email = emailOptional.get();
            } else {
                email = new Email();
            }
            if (statusOptional.isPresent()) {
                status = statusOptional.get();
            } else {
                status = Status.PENDING;
            }
            if (phoneOptional.isPresent()) {
                phone = phoneOptional.get();
            } else {
                phone = new Phone();
            }
            ReadOnlyParcel parcel = new Parcel(trackingNumber, name, phone, email, address, deliveryDate, status,
                    tagList);
            return new AddCommand(parcel);
        } catch (IllegalValueException ive) {
            throw new ParseException(ive.getMessage(), ive);
        }
    }
public AddCommand parse ( String args ) throws ParseException { ArgumentMultimap argMultimap = ArgumentTokenizer . tokenize ( args , PREFIX_TRACKING_NUMBER , PREFIX_NAME , PREFIX_PHONE , PREFIX_EMAIL , PREFIX_ADDRESS , PREFIX_DELIVERY_DATE , PREFIX_STATUS , PREFIX_TAG ) ; if ( ! arePrefixesPresent ( argMultimap , PREFIX_TRACKING_NUMBER , PREFIX_NAME , PREFIX_ADDRESS , PREFIX_DELIVERY_DATE ) ) { throw new ParseException ( String . format ( MESSAGE_INVALID_COMMAND_FORMAT , AddCommand . MESSAGE_USAGE ) ) ; } try { TrackingNumber trackingNumber = ParserUtil . parseTrackingNumber ( argMultimap . getValue ( PREFIX_TRACKING_NUMBER ) ) . get ( ) ; Name name = ParserUtil . parseName ( argMultimap . getValue ( PREFIX_NAME ) ) . get ( ) ; Address address = ParserUtil . parseAddress ( argMultimap . getValue ( PREFIX_ADDRESS ) ) . get ( ) ; DeliveryDate deliveryDate = ParserUtil . parseDeliveryDate ( argMultimap . getValue ( PREFIX_DELIVERY_DATE ) ) . get ( ) ; Set < Tag > tagList = ParserUtil . parseTags ( argMultimap . getAllValues ( PREFIX_TAG ) ) ; Optional < Email > emailOptional = ParserUtil . parseEmail ( argMultimap . getValue ( PREFIX_EMAIL ) ) ; Optional < Status > statusOptional = ParserUtil . parseStatus ( argMultimap . getValue ( PREFIX_STATUS ) ) ; Optional < Phone > phoneOptional = ParserUtil . parsePhone ( argMultimap . getValue ( PREFIX_PHONE ) ) ; Email email ; Status status ; Phone phone ; if ( emailOptional . isPresent ( ) ) { email = emailOptional . get ( ) ; } else { email = new Email ( ) ; } if ( statusOptional . isPresent ( ) ) { status = statusOptional . get ( ) ; } else { status = Status . PENDING ; } if ( phoneOptional . isPresent ( ) ) { phone = phoneOptional . get ( ) ; } else { phone = new Phone ( ) ; } ReadOnlyParcel parcel = new Parcel ( trackingNumber , name , phone , email , address , deliveryDate , status , tagList ) ; return new AddCommand ( parcel ) ; } catch ( IllegalValueException ive ) { throw new ParseException ( ive . getMessage ( ) , ive ) ; } }
Parses the given {@code String} of arguments in the context of the AddCommand
 and returns an AddCommand object for execution.
Parses the given { @code String } of arguments in the context of the AddCommand and returns an AddCommand object for execution .