Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ public URI() {
super(null);
}

private URI(String scheme,
String user,
String password,
String host,
Integer port,
String path,
Map<String, String> parameters,
String url) {
protected URI(final String scheme,
final String user,
final String password,
final String host,
final Integer port,
final String path,
final Map<String, String> parameters,
final String url) {
super(parameters);
this.scheme = scheme;
this.user = user;
Expand Down Expand Up @@ -136,7 +136,7 @@ public int getPort(int defaultPort) {
* @return a new URI instance with the updated scheme.
*/
public URI scheme(String scheme) {
return new URI(scheme, user, password, host, port, path, parameters);
return create(scheme, user, password, host, port, path, parameters);
}

/**
Expand All @@ -147,7 +147,7 @@ public URI scheme(String scheme) {
*/
@Deprecated
public URI schema(String schema) {
return new URI(schema, user, password, host, port, path, parameters);
return create(schema, user, password, host, port, path, parameters);
}

/**
Expand All @@ -157,7 +157,7 @@ public URI schema(String schema) {
* @return a new URI instance with the updated user component
*/
public URI user(String user) {
return new URI(scheme, user, password, host, port, path, parameters);
return create(scheme, user, password, host, port, path, parameters);
}

/**
Expand All @@ -167,7 +167,7 @@ public URI user(String user) {
* @return a new URI instance with the updated password component
*/
public URI password(String password) {
return new URI(scheme, user, password, host, port, path, parameters);
return create(scheme, user, password, host, port, path, parameters);
}

/**
Expand All @@ -177,7 +177,7 @@ public URI password(String password) {
* @return a new URI instance with the updated host.
*/
public URI host(String host) {
return new URI(scheme, user, password, host, port, path, parameters);
return create(scheme, user, password, host, port, path, parameters);
}

/**
Expand All @@ -187,7 +187,7 @@ public URI host(String host) {
* @return a new URI instance with the updated port.
*/
public URI port(Integer port) {
return new URI(scheme, user, password, host, port, path, parameters);
return create(scheme, user, password, host, port, path, parameters);
}

/**
Expand All @@ -198,7 +198,7 @@ public URI port(Integer port) {
* @return a new URI instance with the updated host.
*/
public URI address(String host, Integer port) {
return new URI(scheme, user, password, host, port, path, parameters);
return create(scheme, user, password, host, port, path, parameters);
}

/**
Expand All @@ -208,7 +208,7 @@ public URI address(String host, Integer port) {
* @return a new URI instance with the updated path.
*/
public URI path(String path) {
return new URI(scheme, user, password, host, port, path, parameters);
return create(scheme, user, password, host, port, path, parameters);
}

/**
Expand All @@ -218,7 +218,7 @@ public URI path(String path) {
* @return a new URI instance with the updated path.
*/
public URI parameters(Map<String, String> parameters) {
return new URI(scheme, user, password, host, port, path, parameters);
return create(scheme, user, password, host, port, path, parameters);
}

/**
Expand Down Expand Up @@ -251,7 +251,7 @@ public URI parameter(String key, String value) {
}
newUrl = builder.toString();
}
return new URI(scheme, user, password, host, port, path, newParameters, newUrl);
return create(scheme, user, password, host, port, path, newParameters, newUrl);
}

/**
Expand Down Expand Up @@ -366,6 +366,27 @@ public String toString() {
return getUri();
}

protected URI create(final String scheme,
final String user,
final String password,
final String host,
final Integer port,
final String path,
final Map<String, String> parameters) {
return new URI(scheme, user, password, host, port, path, parameters, null);
}

protected URI create(final String scheme,
final String user,
final String password,
final String host,
final Integer port,
final String path,
final Map<String, String> parameters,
final String url) {
return new URI(scheme, user, password, host, port, path, parameters, url);
}

private static boolean isIpv6(String host) {
return host != null && host.indexOf(':') >= 0;
}
Expand Down
Loading