class UriComponent {

    public static URI resolve(URI baseUri, URI resolvingUri) {
        checkArgument(baseUri != null, "Null base uri isn't allowed");
        checkArgument(resolvingUri != null, "Null resolving uri isn't allowed");
        String resolvingUriStr = resolvingUri.toString();
        if (resolvingUriStr.isEmpty()) {
            return baseUri;
        }
        if (resolvingUriStr.startsWith("?")) {
            String baseUriStr = baseUri.toString();
            int q = baseUriStr.indexOf('?');
            if (q > 0) {
                return normalize(URI.create(baseUriStr.substring(0, q) + resolvingUriStr));
            }
            return normalize(URI.create(baseUriStr + resolvingUriStr));
        }
        return normalize(baseUri.resolve(resolvingUri));
    }

    private  UriComponent();

}