Interface QueryParams
QueryParams provides convenient methods for extracting query parameters from HTTP requests with automatic type conversion for common types like integers, booleans, and doubles.
Access: Available through RequestContext.queryParams()
when
processing HTTP requests in endpoint methods.
Type Safety: The typed getter methods (getInteger(java.lang.String)
, getBoolean(java.lang.String)
, etc.) handle conversion from string values to the requested type, returning
Optional.empty()
if the parameter is missing or cannot be converted.
Multiple Values: Query parameters can have multiple values (e.g.,
?tag=java&tag=http
). Use getAll(String)
to retrieve all values for a parameter name.
Map Conversion: Use toMap()
for a simple key-value map (first value
only) or toMultiMap()
to preserve all values for parameters that appear multiple times.
-
Method Summary
Modifier and TypeMethodDescriptionReturns the value of all parameters with the given key.<T> List
<T> Returns the value of all parameters with the given key using mapper function.getBoolean
(String key) Returns the Boolean value of the first parameter with the given key if it exists.Returns the Double value of the first parameter with the given key if it exists.getInteger
(String key) Returns the Integer value of the first parameter with the given key if it exists.Returns the Long value of the first parameter with the given key if it exists.Returns the value of the first parameter with the given key if it exists.toMap()
Returns a key/value map of the parameters.Returns a `Map` of all parameters.
-
Method Details
-
getString
Returns the value of the first parameter with the given key if it exists. -
getInteger
Returns the Integer value of the first parameter with the given key if it exists. -
getLong
Returns the Long value of the first parameter with the given key if it exists. -
getBoolean
Returns the Boolean value of the first parameter with the given key if it exists. -
getDouble
Returns the Double value of the first parameter with the given key if it exists. -
getAll
Returns the value of all parameters with the given key. -
getAll
Returns the value of all parameters with the given key using mapper function. -
toMap
Returns a key/value map of the parameters. Use the `toMultiMap()` method to return all parameters if keys may occur multiple times. -
toMultiMap
Returns a `Map` of all parameters. Use the `toMap()` method to filter out entries with duplicated keys.
-