Package io.micronaut.http.uri
Interface UriBuilder
public interface UriBuilder
Helper class for building URIs and handle encoding correctly.
- Since:
- 1.0.2
- Author:
- graemerocher
-
Method Summary
Modifier and TypeMethodDescriptionbuild()The constructed URI.Expands the URI if it is a template, using the given values.Sets the URI fragment.Sets the URI host.static @NonNull UriBuilderof(@NonNull CharSequence uri) Create aUriBuilderwith the given base URI as a starting point.static @NonNull UriBuilderCreate aUriBuilderwith the given base URI as a starting point.Appends the given path to the existing path correctly handling '/'.port(int port) Sets the URI port.queryParam(String name, Object... values) Adds a query parameter for the give name and values.replacePath(@Nullable String path) Replaces the existing path if any.replaceQueryParam(String name, Object... values) Adds a query parameter for the give name and values.Sets the URI scheme.Sets the URI user info.
-
Method Details
-
fragment
Sets the URI fragment.- Parameters:
fragment- The fragment- Returns:
- This builder
-
scheme
Sets the URI scheme.- Parameters:
scheme- The scheme- Returns:
- This builder
-
userInfo
Sets the URI user info.- Parameters:
userInfo- The use info- Returns:
- This builder
-
host
Sets the URI host.- Parameters:
host- The host to use- Returns:
- This builder
-
port
Sets the URI port.- Parameters:
port- The port to use- Returns:
- This builder
-
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
Replaces the existing path if any. If path is null it is simply ignored.- Parameters:
path- The path- Returns:
- This builder
-
queryParam
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
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
The constructed URI.- Returns:
- Build the URI
- Throws:
UriSyntaxException- if the URI to be constructed is invalid
-
expand
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
Create aUriBuilderwith the given base URI as a starting point.- Parameters:
uri- The URI- Returns:
- The builder
-
of
Create aUriBuilderwith the given base URI as a starting point.- Parameters:
uri- The URI- Returns:
- The builder
-