src/main/java/com/mobiquityinc/packer/Parser.java
protected static Package parsePackage(String things) throws APIException {
        Matcher matcher = PACKAGE_PATTERN.matcher(things);
        if (matcher.find()) {
            int capacity = Integer.valueOf(matcher.group(1));
            if (capacity > MAX_PACKAGE_WEIGHT) {
                throw new APIException(String.format("Max weight that a package can take must be ≤ 100, " +
                        "but input capacity is %d", capacity));
            }
            return Package.builder()
                    .capacity(capacity)
                    .things(parseThings(matcher.group(2).trim()))
                    .build();
        } else {
            throw new APIException(String.format("Unable to parse line '%s'", things));
        }
    }
/**
     * @param things a line contains the weight that the package can take (before the colon)
     *               and the list of things need to be chosen.
     * @return parsed Package object
     * @throws APIException if the line doesn't match the pattern or weight of the package
     * exceeds constraint.
     */
@param things a line contains the weight that the package can take (before the colon)
and the list of things need to be chosen.
@return parsed Package object
@throws APIException if the line doesn't match the pattern or weight of the package
exceeds constraint.
@param things a line contains the weight that the package can take ( before the colon ) and the list of things need to be chosen . @return parsed Package object @throws APIException if the line doesn ' t match the pattern or weight of the package exceeds constraint .
protected static Package parsePackage(String things) throws APIException {
        Matcher matcher = PACKAGE_PATTERN.matcher(things);
        if (matcher.find()) {
            int capacity = Integer.valueOf(matcher.group(1));
            if (capacity > MAX_PACKAGE_WEIGHT) {
                throw new APIException(String.format("Max weight that a package can take must be ≤ 100, " +
                        "but input capacity is %d", capacity));
            }
            return Package.builder()
                    .capacity(capacity)
                    .things(parseThings(matcher.group(2).trim()))
                    .build();
        } else {
            throw new APIException(String.format("Unable to parse line '%s'", things));
        }
    }
protected static Package parsePackage ( String things ) throws APIException { Matcher matcher = PACKAGE_PATTERN . matcher ( things ) ; if ( matcher . find ( ) ) { int capacity = Integer . valueOf ( matcher . group ( 1 ) ) ; if ( capacity > MAX_PACKAGE_WEIGHT ) { throw new APIException ( String . format ( "Max weight that a package can take must be ≤ 100, " + "but input capacity is %d" , capacity ) ) ; } return Package . builder ( ) . capacity ( capacity ) . things ( parseThings ( matcher . group ( 2 ) . trim ( ) ) ) . build ( ) ; } else { throw new APIException ( String . format ( "Unable to parse line '%s'" , things ) ) ; } }
@param things a line contains the weight that the package can take (before the colon)
               and the list of things need to be chosen.
@param things a line contains the weight that the package can take ( before the colon ) and the list of things need to be chosen .