Class UrlBuilder
UrlBuilder
helps creating valid URLs that automatically
adapt based on the current execution Context
and target Route
.
Using this class will ensure that the right state is always passed on, and that the correct URL path is always used.
UrlBuilder
is not intended to be instantiated directly, but
rather through Context.urlFor(Route)
.
- Since:
- 1.0
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final record
The segments that are generated by the URL builder. -
Constructor Summary
ConstructorDescriptionUrlBuilder
(String rootUrl, Route route) UrlBuilder
(Context context, Route route) -
Method Summary
Modifier and TypeMethodDescriptionSets a particular fragment for this URL, it will be appended at the end, separated by a#
.Generates the segments for the current state of theUrlBuilder
.Sets an outgoing parameter to a particular value.Sets an outgoing parameter to a particular value.Sets an outgoing parameter to a particular value array.Sets a parameters for all the entries in the provided parameter map.Sets a particular pathinfo for this URL, it will automatically be encoded.toString()
Generates the string version for the current state of theUrlBuilder
.
-
Constructor Details
-
UrlBuilder
-
UrlBuilder
-
-
Method Details
-
pathInfo
Sets a particular pathinfo for this URL, it will automatically be encoded.If no pathinfo is manually set, the destination route has pathinfo mapping configured, and the parameters are available to construct that pathinfo, then RIFE2 will automatically create a correct pathinfo.
- Parameters:
pathInfo
- the explicit pathinfo to use- Returns:
- this
UrlBuilder
instance - Since:
- 1.0
-
param
Sets an outgoing parameter to a particular value.This will override any automatic outgoing parameters that are being published by the
Context
.- Parameters:
name
- the name of the parametervalue
- the value of the parameter- Returns:
- this
UrlBuilder
instance - Since:
- 1.6.0
-
param
Sets an outgoing parameter to a particular value.This will override any automatic outgoing parameters that are being published by the
Context
.- Parameters:
name
- the name of the parametervalue
- the value of the parameter- Returns:
- this
UrlBuilder
instance - Since:
- 1.0
-
param
Sets an outgoing parameter to a particular value array.This will override any automatic outgoing parameters that are being published by the
Context
.- Parameters:
name
- the name of the parametervalue
- the value of the parameter- Returns:
- this
UrlBuilder
instance - Since:
- 1.0
-
params
Sets a parameters for all the entries in the provided parameter map.This will override any automatic outgoing parameters that are being published by the
Context
.- Parameters:
parameters
- the map of parameters that will be set- Returns:
- this
UrlBuilder
instance - Since:
- 1.0
-
fragment
Sets a particular fragment for this URL, it will be appended at the end, separated by a#
.- Parameters:
fragment
- the fragment to use- Returns:
- this
UrlBuilder
instance - Since:
- 1.0
-
generateSegments
Generates the segments for the current state of theUrlBuilder
.- Returns:
- the segments of the URL that's being built
- Since:
- 1.0
-
toString
Generates the string version for the current state of theUrlBuilder
.
-