public class EndpointUtil extends Object
Constructor and Description |
---|
EndpointUtil() |
Modifier and Type | Method and Description |
---|---|
static String |
getHost(String endpointUrl) |
static String |
getPath(String endpointUrl)
Get the path component from an endpoint URL.
|
static int |
getPort(String endpointUrl) |
static String |
getScheme(String endpointUrl) |
static EndpointDescription |
updateUrl(EndpointDescription endpoint,
String hostname)
Replace the hostname in the endpoint URL field of
endpoint with a new one. |
static EndpointDescription |
updateUrl(EndpointDescription endpoint,
String hostname,
int port)
Replace the hostname and port in the endpoint URL field of
endpoint with new ones. |
@Nonnull public static String getPath(@Nonnull String endpointUrl)
An empty path becomes "/" and trailing "/" are removed from non-empty paths.
endpointUrl
- the endpoint URL.public static EndpointDescription updateUrl(@Nonnull EndpointDescription endpoint, @Nullable String hostname)
endpoint
with a new one.
All other fields of the original EndpointDescription
remain equal.
If the endpoint URL does not match the expected format the original endpoint is returned.
endpoint
- the EndpointDescription
to modify.hostname
- the new hostname to use. A null value will result in the original hostname being used.EndpointDescription
in which the hostname of the endpoint URL has been replaced with
hostname
.public static EndpointDescription updateUrl(@Nonnull EndpointDescription endpoint, @Nullable String hostname, int port)
endpoint
with new ones.
All other fields of the original EndpointDescription
remain equal.
If the endpoint URL does not match the expected format the original endpoint is returned.
endpoint
- the EndpointDescription
to modify.hostname
- the new hostname to use. A null value will result in the original hostname being used.port
- the new port to use. Any value <= 0 will result in the original port being used.EndpointDescription
in which the hostname of the endpoint URL has been replaced with
hostname
.Copyright © 2020. All rights reserved.