class Utils {

    public static int validatePortNumber(String portStringValue) {
        final int portNumber;
        final StringBuilder exceptionMessageBuilder = new StringBuilder();
        exceptionMessageBuilder.append("Invalid value '").append(portStringValue)
                .append("' for input '").append(HttpClientInputs.PROXY_PORT)
                .append("'. Valid Values: -1 and integer values greater than 0. ");

        try {
            portNumber = Integer.parseInt(portStringValue);
            if ((portNumber <= 0) && (portNumber != -1)) {
                throw new IllegalArgumentException(exceptionMessageBuilder.toString());
            }
        } catch (NumberFormatException e) {
            throw new IllegalArgumentException(exceptionMessageBuilder.toString(), e);
        }
        return portNumber;
    }

}