src/main/java/seedu/address/bot/parcel/ParcelParser.java
public ReadOnlyParcel 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(PARCEL_PARSER_ERROR);
        }

        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.getInstance("Pending");
            }

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

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

            return parcel;
        } catch (IllegalValueException ive) {
            throw new ParseException(ive.getMessage(), ive);
        }
    }
/**
     * Parse ia a method to parse a String containing the details of a parcel into a ReadOnlyParcel
     * @param args represent the details of the parcels with the prefixes.
     * @return a ReadOnlyParcel that has the details corresponding to the arguments
     * @throws ParseException if we are unable to understand the parcel information
     */
Parse ia a method to parse a String containing the details of a parcel into a ReadOnlyParcel
@param args represent the details of the parcels with the prefixes.
@return a ReadOnlyParcel that has the details corresponding to the arguments
@throws ParseException if we are unable to understand the parcel information
Parse ia a method to parse a String containing the details of a parcel into a ReadOnlyParcel @param args represent the details of the parcels with the prefixes . @return a ReadOnlyParcel that has the details corresponding to the arguments @throws ParseException if we are unable to understand the parcel information
public ReadOnlyParcel 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(PARCEL_PARSER_ERROR);
        }
        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.getInstance("Pending");
            }
            if (phoneOptional.isPresent()) {
                phone = phoneOptional.get();
            } else {
                phone = new Phone();
            }
            ReadOnlyParcel parcel = new Parcel(trackingNumber, name, phone, email, address, deliveryDate, status,
                    tagList);
            return parcel;
        } catch (IllegalValueException ive) {
            throw new ParseException(ive.getMessage(), ive);
        }
    }
public ReadOnlyParcel 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 ( PARCEL_PARSER_ERROR ) ; } 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 . getInstance ( "Pending" ) ; } if ( phoneOptional . isPresent ( ) ) { phone = phoneOptional . get ( ) ; } else { phone = new Phone ( ) ; } ReadOnlyParcel parcel = new Parcel ( trackingNumber , name , phone , email , address , deliveryDate , status , tagList ) ; return parcel ; } catch ( IllegalValueException ive ) { throw new ParseException ( ive . getMessage ( ) , ive ) ; } }
Parse ia a method to parse a String containing the details of a parcel into a ReadOnlyParcel
 @param args represent the details of the parcels with the prefixes.
Parse ia a method to parse a String containing the details of a parcel into a ReadOnlyParcel @param args represent the details of the parcels with the prefixes .