Package io.micronaut.http.uri
Interface UriBuilder
-
public interface UriBuilderHelper class for building URIs and handle encoding correctly.- Since:
- 1.0.2
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description java.net.URIbuild()The constructed URI.java.net.URIexpand(java.util.Map<java.lang.String,? super java.lang.Object> values)Expands the URI if it is a template, using the given values.UriBuilderfragment(java.lang.String fragment)Sets the URI fragment.UriBuilderhost(java.lang.String host)Sets the URI host.static UriBuilderof(java.lang.CharSequence uri)Create aUriBuilderwith the given base URI as a starting point.static UriBuilderof(java.net.URI uri)Create aUriBuilderwith the given base URI as a starting point.UriBuilderpath(java.lang.String path)Appends the given path to the existing path correctly handling '/'.UriBuilderport(int port)Sets the URI port.UriBuilderqueryParam(java.lang.String name, java.lang.Object... values)Adds a query parameter for the give name and values.UriBuilderreplacePath(java.lang.String path)Replaces the existing path if any.UriBuilderreplaceQueryParam(java.lang.String name, java.lang.Object... values)Adds a query parameter for the give name and values.UriBuilderscheme(java.lang.String scheme)Sets the URI scheme.UriBuilderuserInfo(java.lang.String userInfo)Sets the URI user info.
-
-
-
Method Detail
-
fragment
@NonNull UriBuilder fragment(@Nullable java.lang.String fragment)
Sets the URI fragment.- Parameters:
fragment- The fragument- Returns:
- This builder
-
scheme
@NonNull UriBuilder scheme(@Nullable java.lang.String scheme)
Sets the URI scheme.- Parameters:
scheme- The scheme- Returns:
- This builder
-
userInfo
@NonNull UriBuilder userInfo(@Nullable java.lang.String userInfo)
Sets the URI user info.- Parameters:
userInfo- The use info- Returns:
- This builder
-
host
@NonNull UriBuilder host(@Nullable java.lang.String host)
Sets the URI host.- Parameters:
host- The host to use- Returns:
- This builder
-
port
@NonNull UriBuilder port(int port)
Sets the URI port.- Parameters:
port- The port to use- Returns:
- This builder
-
path
@NonNull UriBuilder path(@Nullable java.lang.String path)
Appends the given path to the existing path correctly handling '/'. If path is null it is simply ignored.- Parameters:
path- The path- Returns:
- This builder
-
replacePath
@NonNull UriBuilder replacePath(@Nullable java.lang.String path)
Replaces the existing path if any. If path is null it is simply ignored.- Parameters:
path- The path- Returns:
- This builder
-
queryParam
@NonNull UriBuilder queryParam(java.lang.String name, java.lang.Object... values)
Adds a query parameter for the give name and values. The values will be URI encoded. If either name or values are null the value will be ignored.- Parameters:
name- The namevalues- The values- Returns:
- This builder
-
replaceQueryParam
@NonNull UriBuilder replaceQueryParam(java.lang.String name, java.lang.Object... values)
Adds a query parameter for the give name and values. The values will be URI encoded. If either name or values are null the value will be ignored.- Parameters:
name- The namevalues- The values- Returns:
- This builder
-
build
@NonNull java.net.URI build()
The constructed URI.- Returns:
- Build the URI
- Throws:
UriSyntaxException- if the URI to be constructed is invalid
-
expand
@NonNull java.net.URI expand(java.util.Map<java.lang.String,? super java.lang.Object> values)
Expands the URI if it is a template, using the given values.- Parameters:
values- Expands the URI with the given values.- Returns:
- Build the URI
-
of
@NonNull static UriBuilder of(@NonNull java.net.URI uri)
Create aUriBuilderwith the given base URI as a starting point.- Parameters:
uri- The URI- Returns:
- The builder
-
of
@NonNull static UriBuilder of(@NonNull java.lang.CharSequence uri)
Create aUriBuilderwith the given base URI as a starting point.- Parameters:
uri- The URI- Returns:
- The builder
-
-