- All Known Subinterfaces:
UriQuery
,UriQueryWriteable
public interface Parameters
Parameters abstraction (used by any component that has named parameters with possible multiple values).
This is a read-only access to the parameters.
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final GenericType
<Parameters> Generic type for parameters. -
Method Summary
Modifier and TypeMethodDescriptionGet all values.Get all values using a default value supplier if the parameter does not exist.A list of values for the named parameter.Get all values using a default value supplier if the parameter does not exist.static Parameters.Builder
Creates a newParameters.Builder
ofParameters
.Name of the component of these parameters.boolean
Whether these parameters contain the provided name.static Parameters
Read only parameters based on a map.static Parameters
createSingleValueMap
(String component, Map<String, String> params) Read only parameters based on a map with just a single value.static Parameters
Create empty (named) parameters.Get the first value as an optional.Get the first value.default boolean
isEmpty()
Whether these parameters are empty.names()
Set of parameter names.int
size()
Number of parameter names in these parameters.toMap()
Get a map representation of these parameters.
-
Field Details
-
GENERIC_TYPE
Generic type for parameters.
-
-
Method Details
-
builder
Creates a newParameters.Builder
ofParameters
.- Parameters:
component
- component these parameters represent (such as request headers)- Returns:
- builder instance
-
empty
Create empty (named) parameters.- Parameters:
component
- component of the parameters to correctly report errors- Returns:
- new named parameters with no values
-
create
Read only parameters based on a map.- Parameters:
component
- component of the parameters to correctly report errorsparams
- underlying map- Returns:
- new named parameters with values based on the map
-
createSingleValueMap
Read only parameters based on a map with just a single value.- Parameters:
component
- component of the parameters to correctly report errorsparams
- underlying map- Returns:
- new named parameters with values based on the map
-
all
Get all values.- Parameters:
name
- name of the parameter- Returns:
- all values as a list
- Throws:
NoSuchElementException
- in case the name is not present
-
all
Get all values using a default value supplier if the parameter does not exist.- Parameters:
name
- name of the parameterdefaultValues
- default values supplier to use if parameter is not present- Returns:
- all values as a list
-
allValues
A list of values for the named parameter.- Parameters:
name
- name of the parameter- Returns:
- list of parameter values, mappable to other types
- Throws:
NoSuchElementException
- in case the name is not present in these parameters
-
allValues
Get all values using a default value supplier if the parameter does not exist.- Parameters:
name
- name of the parameterdefaultValues
- default values supplier to use if parameter is not present- Returns:
- all values as a list
-
get
Get the first value.- Parameters:
name
- name of the parameter- Returns:
- first value
- Throws:
NoSuchElementException
- in case the name is not present
-
first
Get the first value as an optional. Managing optionals has performance impact. If performance is of issue, usecontains(String)
andget(String)
instead.- Parameters:
name
- name of the parameter- Returns:
- first value or empty optional
-
contains
Whether these parameters contain the provided name.- Parameters:
name
- name of the parameter- Returns:
true
if the parameter is present,false
otherwise
-
isEmpty
default boolean isEmpty()Whether these parameters are empty.- Returns:
true
if there is no parameter defined
-
size
int size()Number of parameter names in these parameters.- Returns:
- size of these parameters
-
names
Set of parameter names.- Returns:
- names available in these parameters
-
component
String component()Name of the component of these parameters.- Returns:
- component name
-
toMap
Get a map representation of these parameters. Changes to the map will not be propagated to this instance.- Returns:
- a new map
-