HeadersReadOnlyParameterspublic interface Parameters
key : value pairs where key is a String with potentially multiple values.
This structure represents query parameters, headers and path parameters in e.g. HttpRequest.
Interface focus on most convenient use cases in HTTP Request and Response processing, like
// Get and map with default
.first("count").map(Integer::new).orElse(0);
// Find max in multiple values
.all("counts").stream().mapToInt(Integer::valueOf).max().orElse(0);
Mutable operations are defined in two forms:
put... create or replace association.add... create association or add values to existing association.
It is possible to use toMap() method to get immutable map view of data.
Various static factory methods can be used to create common implementations.
| Modifier and Type | Method | Description |
|---|---|---|
void |
add(java.lang.String key,
java.lang.Iterable<java.lang.String> values) |
Adds specified values tu association with the specified key (optional operation).
|
void |
add(java.lang.String key,
java.lang.String... values) |
Adds specified values tu association with the specified key (optional operation).
|
void |
addAll(Parameters parameters) |
Copies all of the mappings from the specified
parameters to this instance adding values to existing associations
(optional operation). |
java.util.List<java.lang.String> |
all(java.lang.String name) |
Returns an unmodifiable List of all of the values of the given named
parameter.
|
java.util.List<java.lang.String> |
computeIfAbsent(java.lang.String key,
java.util.function.Function<java.lang.String,java.lang.Iterable<java.lang.String>> values) |
If the specified key is not already associated with a value computes new association using the given function and returns
empty
List, else returns the current value (optional operation). |
java.util.List<java.lang.String> |
computeSingleIfAbsent(java.lang.String key,
java.util.function.Function<java.lang.String,java.lang.String> value) |
If the specified key is not already associated with a value computes new association using the given function and returns
empty
List, else returns the current value (optional operation). |
java.util.Optional<java.lang.String> |
first(java.lang.String name) |
Returns an
Optional containing the first value of the given
parameter (and possibly multi-valued) parameter. |
java.util.List<java.lang.String> |
put(java.lang.String key,
java.lang.Iterable<java.lang.String> values) |
Associates specified values with the specified key (optional operation).
|
java.util.List<java.lang.String> |
put(java.lang.String key,
java.lang.String... values) |
Associates specified values with the specified key (optional operation).
|
void |
putAll(Parameters parameters) |
Copies all of the mappings from the specified
parameters to this instance replacing values of existing associations
(optional operation). |
java.util.List<java.lang.String> |
putIfAbsent(java.lang.String key,
java.lang.Iterable<java.lang.String> values) |
If the specified key is not already associated with a value associates it with the given value and returns empty
List, else returns the current value (optional operation). |
java.util.List<java.lang.String> |
putIfAbsent(java.lang.String key,
java.lang.String... values) |
If the specified key is not already associated with a value associates it with the given value and returns empty
List, else returns the current value (optional operation). |
java.util.List<java.lang.String> |
remove(java.lang.String key) |
Removes the mapping for a key if it is present (optional operation).
|
java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
toMap() |
Returns a copy of parameters as a Map.
|
static Parameters |
toUnmodifiableParameters(Parameters parameters) |
Returns an unmodifiable view.
|
static Parameters toUnmodifiableParameters(Parameters parameters)
parameters - a parameters for unmodifiable view.java.lang.NullPointerException - if parameter parameters is null.java.util.Optional<java.lang.String> first(java.lang.String name)
Optional containing the first value of the given
parameter (and possibly multi-valued) parameter. If the parameter is
not present, then the returned Optional is empty.name - the parameter nameOptional<V> for the first named valuejava.lang.NullPointerException - if name is nulljava.util.List<java.lang.String> all(java.lang.String name)
name - the parameter nameList of values with zero or greater sizejava.lang.NullPointerException - if name is nulljava.util.List<java.lang.String> put(java.lang.String key,
java.lang.String... values)
key - key with which the specified value is to be associatedvalues - value to be associated with the specified keyList if there was no mapping for key.java.lang.NullPointerException - if the specified key is null.java.lang.UnsupportedOperationException - if put operation is not supported (unmodifiable Parameters).java.util.List<java.lang.String> put(java.lang.String key,
java.lang.Iterable<java.lang.String> values)
key - key with which the specified value is to be associatedvalues - value to be associated with the specified key. If null then association will be removed.List if there was no mapping for key.java.lang.NullPointerException - if the specified key is null.java.lang.UnsupportedOperationException - if put operation is not supported (unmodifiable Parameters).java.util.List<java.lang.String> putIfAbsent(java.lang.String key,
java.lang.String... values)
List, else returns the current value (optional operation).key - key with which the specified value is to be associatedvalues - value to be associated with the specified keyList if there was no mapping for key.java.lang.NullPointerException - if the specified key is null.java.lang.UnsupportedOperationException - if put operation is not supported (unmodifiable Parameters).java.util.List<java.lang.String> putIfAbsent(java.lang.String key,
java.lang.Iterable<java.lang.String> values)
List, else returns the current value (optional operation).key - key with which the specified value is to be associatedvalues - value to be associated with the specified keyList if there was no mapping for key.java.lang.NullPointerException - if the specified key is null.java.lang.UnsupportedOperationException - if put operation is not supported (unmodifiable Parameters).java.util.List<java.lang.String> computeIfAbsent(java.lang.String key,
java.util.function.Function<java.lang.String,java.lang.Iterable<java.lang.String>> values)
List, else returns the current value (optional operation).key - key with which the specified value is to be associatedvalues - value to be associated with the specified keyList if function returns nulljava.lang.NullPointerException - if the specified key is nulljava.lang.UnsupportedOperationException - if put operation is not supported (unmodifiable Parameters)java.lang.IllegalStateException - if the computation detectably
attempts a recursive update to this map that would
otherwise never completejava.lang.RuntimeException - or Error if the mappingFunction does so,
in which case the mapping is left unestablishedjava.util.List<java.lang.String> computeSingleIfAbsent(java.lang.String key,
java.util.function.Function<java.lang.String,java.lang.String> value)
List, else returns the current value (optional operation).key - a key with which the specified value is to be associatedvalue - a single value to be associated with the specified keyList if function returns nulljava.lang.NullPointerException - if the specified key is null.java.lang.UnsupportedOperationException - if put operation is not supported (unmodifiable Parameters).java.lang.IllegalStateException - if the computation detectably
attempts a recursive update to this map that would
otherwise never completejava.lang.RuntimeException - or Error if the mappingFunction does so,
in which case the mapping is left unestablishedvoid putAll(Parameters parameters)
parameters to this instance replacing values of existing associations
(optional operation).parameters - to copy.java.lang.NullPointerException - if the specified parameters are null.java.lang.UnsupportedOperationException - if put operation is not supported (unmodifiable Parameters).void add(java.lang.String key,
java.lang.String... values)
key - key with which the specified value is to be associatedvalues - value to be add to association with the specified keyjava.lang.NullPointerException - if the specified key is null.java.lang.UnsupportedOperationException - if put operation is not supported (unmodifiable Parameters).void add(java.lang.String key,
java.lang.Iterable<java.lang.String> values)
key - key with which the specified value is to be associatedvalues - value to be add to association with the specified key. If null then noting will be add.java.lang.NullPointerException - if the specified key is null.java.lang.UnsupportedOperationException - if put operation is not supported (unmodifiable Parameters).void addAll(Parameters parameters)
parameters to this instance adding values to existing associations
(optional operation).parameters - to copy.java.lang.NullPointerException - if the specified parameters are null.java.lang.UnsupportedOperationException - if put operation is not supported (unmodifiable Parameters).java.util.List<java.lang.String> remove(java.lang.String key)
key - key whose mapping is to be removed.List.java.util.Map<java.lang.String,java.util.List<java.lang.String>> toMap()
MapCopyright © 2018 Oracle Corporation. All rights reserved.