public static URI toUri(String endpoint, Protocol protocol) {
        if (endpoint == null) {
            throw new IllegalArgumentException("endpoint cannot be null");
        }

        /*
         * If the endpoint doesn't explicitly specify a protocol to use, then
         * we'll defer to the default protocol specified in the client
         * configuration.
         */
        if (!endpoint.contains("://")) {
            endpoint = protocol.toString() + "://" + endpoint;
        }

        try {
            return new URI(endpoint);
        } catch (URISyntaxException e) {
            throw new IllegalArgumentException(e);
        }
    }
public static URI toUri ( String endpoint , Protocol protocol ) { if ( endpoint == null ) { throw new IllegalArgumentException ( "endpoint cannot be null" ) ; } if ( ! endpoint . contains ( "://" ) ) { endpoint = protocol . toString ( ) + "://" + endpoint ; } try { return new URI ( endpoint ) ; } catch ( URISyntaxException e ) { throw new IllegalArgumentException ( e ) ; } }
Returns an URI for the given endpoint.
Prefixes the protocol if the endpoint given does not have it.

@throws IllegalArgumentException if the inputs are null.