java.lang.Object
io.helidon.common.http.HashParameters
- Direct Known Subclasses:
HashHeaders
A
Map
-based Parameters
implementation with keys and immutable List
of values that needs to be copied
on each write.
By default, this implementation uses case-sensitive keys but a subclass can override the map factory methods
emptyMapForReads()
and emptyMapForUpdates()
to control the specific type of map used.
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
Iterable
around an array (to avoid uses ofArray.asList
) to get anIterable
. -
Constructor Summary
ModifierConstructorDescriptionprotected
Creates a new instance.protected
HashParameters
(Parameters initialContent) Creates a new instance from provided data.protected
Creates a new instance from provided data, typically either anotherParameters
instance or a map's entry set.protected
HashParameters
(Map<String, List<String>> initialContent) Creates a new instance from provided data. -
Method Summary
Modifier and TypeMethodDescriptionAdds specified values to association with the specified key (optional operation).Adds specified values to association with the specified key (optional operation).addAll
(Parameters parameters) Copies all of the mappings from the specifiedparameters
to this instance adding values to existing associations (optional operation).Returns an unmodifiable List of all of the values of the given named parameter.If the specified key is not already associated with a value computes new association using the given function and returns emptyList
, else returns the current value (optional operation).computeSingleIfAbsent
(String key, Function<String, String> value) If the specified key is not already associated with a value computes new association using the given function and returns emptyList
, else returns the current value (optional operation).static HashParameters
concat
(Parameters... parameters) Creates new instance ofHashParameters
as a concatenation of provided parameters.protected static <T extends HashParameters>
Tconcat
(Iterable<? extends Iterable<Map.Entry<String, List<String>>>> contentSources, Supplier<T> emptyFactory, Function<Iterable<Map.Entry<String, List<String>>>, T> singletonFactory) Creates a new instance of the correctHashParameters
subclass as a concatenation of the provided sources.static HashParameters
concat
(Iterable<Parameters> parameters) Creates new instance ofHashParameters
as a concatenation of provided parameters.static HashParameters
create()
Creates a new empty instanceHashParameters
.static HashParameters
create
(Parameters initialContent) Creates a new instanceHashParameters
from provided data.static HashParameters
Creates a new instance ofHashParameters
from a single provided Parameter or Map.static HashParameters
Creates a new instance ofHashParameters
from a single provided Map.Returns an emptyMap
suitable for case-sensitivity or case-insensitivity and optimized for read-only access.protected ConcurrentMap<String,
List<String>> Returns an emptyMap
suitable for case-sensitivity or case-insensitivity and for read-write access.boolean
Returns anOptional
containing the first value of the given parameter (and possibly multi-valued) parameter.int
hashCode()
iterator()
Associates specified values with the specified key (optional operation).Associates specified values with the specified key (optional operation).putAll
(Parameters parameters) Copies all of the mappings from the specifiedparameters
to this instance replacing values of existing associations (optional operation).putIfAbsent
(String key, Iterable<String> values) If the specified key is not already associated with a value associates it with the given value and returns emptyList
, else returns the current value (optional operation).putIfAbsent
(String key, String... values) If the specified key is not already associated with a value associates it with the given value and returns emptyList
, else returns the current value (optional operation).Removes the mapping for a key if it is present (optional operation).toMap()
Returns a copy of parameters as a Map.toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
HashParameters
protected HashParameters()Creates a new instance. -
HashParameters
Creates a new instance from provided data. Initial data are copied.- Parameters:
initialContent
- initial content.
-
HashParameters
Creates a new instance from provided data, typically either anotherParameters
instance or a map's entry set. Initial data are copied.- Parameters:
initialContent
- initial content
-
HashParameters
Creates a new instance from provided data. Initial data is copied.- Parameters:
initialContent
- initial content.
-
-
Method Details
-
create
Creates a new empty instanceHashParameters
.- Returns:
- a new instance of
HashParameters
.
-
create
Creates a new instance ofHashParameters
from a single provided Map. Initial data is copied.- Parameters:
initialContent
- initial content.- Returns:
- a new instance of
HashParameters
initialized with the given content.
-
create
Creates a new instanceHashParameters
from provided data. Initial data is copied.- Parameters:
initialContent
- initial content.- Returns:
- a new instance of
HashParameters
initialized with the given content.
-
create
Creates a new instance ofHashParameters
from a single provided Parameter or Map. Initial data is copied.- Parameters:
initialContent
- initial content.- Returns:
- a new instance of
HashParameters
initialized with the given content.
-
concat
Creates new instance ofHashParameters
as a concatenation of provided parameters. Values for keys found across the provided parameters are "concatenated" into aList
entry for their respective key in the createdHashParameters
instance.- Parameters:
parameters
- parameters to concatenate.- Returns:
- a new instance of
HashParameters
that represents the concatenation of the provided parameters.
-
concat
Creates new instance ofHashParameters
as a concatenation of provided parameters. Values for keys found across the provided parameters are "concatenated" into aList
entry for their respective key in the createdHashParameters
instance.- Parameters:
parameters
- parameters to concatenate.- Returns:
- a new instance of
HashParameters
that represents the concatenation of the provided parameters.
-
iterator
Description copied from interface:Parameters
Implementations should override this default with a more efficient implementation.
-
concat
protected static <T extends HashParameters> T concat(Iterable<? extends Iterable<Map.Entry<String, List<String>>>> contentSources, Supplier<T> emptyFactory, Function<Iterable<Map.Entry<String, List<String>>>, T> singletonFactory) Creates a new instance of the correctHashParameters
subclass as a concatenation of the provided sources. Values for keys found across the sources are "concatenated" into aList
entry for their respective key in the createdHashParameters
(or subclass) instance.- Type Parameters:
T
- type of the named value lists implementation to create- Parameters:
contentSources
-Iterable
over the sources whose contents are to be combinedemptyFactory
- factory for an empty named value lists implementationsingletonFactory
- factory for a named value lists implementation preloaded with one source's data- Returns:
- new named value lists implementation containing the combined data from the sources
-
emptyMapForUpdates
Returns an emptyMap
suitable for case-sensitivity or case-insensitivity and for read-write access.Typical implementations should return a concurrent implementation.
- Returns:
- empty
Map
implementation with correct case-sensitivity behavior and suitable for read-write access
-
emptyMapForReads
Returns an emptyMap
suitable for case-sensitivity or case-insensitivity and optimized for read-only access.Typical implementations should not return a concurrent implementation.
- Returns:
- empty
Map
implementation with correct case-sensitivity behavior and optimized for read-only access
-
first
Description copied from interface:Parameters
Returns anOptional
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.- Specified by:
first
in interfaceParameters
- Parameters:
name
- the parameter name- Returns:
- an
Optional<V>
for the first named value
-
all
Description copied from interface:Parameters
Returns an unmodifiable List of all of the values of the given named parameter. Always returns a List, which may be empty if the parameter is not present.- Specified by:
all
in interfaceParameters
- Parameters:
name
- the parameter name- Returns:
- a
List
of values with zero or greater size
-
put
Description copied from interface:Parameters
Associates specified values with the specified key (optional operation). If parameters previously contained a mapping for the key, the old values fully replaced.- Specified by:
put
in interfaceParameters
- Parameters:
key
- key with which the specified value is to be associatedvalues
- value to be associated with the specified key- Returns:
- the previous values associated with key, or empty
List
if there was no mapping for key.
-
put
Description copied from interface:Parameters
Associates specified values with the specified key (optional operation). If parameters previously contained a mapping for the key, the old values fully replaced.- Specified by:
put
in interfaceParameters
- Parameters:
key
- key with which the specified value is to be associatedvalues
- value to be associated with the specified key. Ifnull
then association will be removed.- Returns:
- the previous values associated with key, or empty
List
if there was no mapping for key.
-
putIfAbsent
Description copied from interface:Parameters
If the specified key is not already associated with a value associates it with the given value and returns emptyList
, else returns the current value (optional operation).- Specified by:
putIfAbsent
in interfaceParameters
- Parameters:
key
- key with which the specified value is to be associatedvalues
- value to be associated with the specified key- Returns:
- the previous values associated with key, or empty
List
if there was no mapping for key.
-
putIfAbsent
Description copied from interface:Parameters
If the specified key is not already associated with a value associates it with the given value and returns emptyList
, else returns the current value (optional operation).- Specified by:
putIfAbsent
in interfaceParameters
- Parameters:
key
- key with which the specified value is to be associatedvalues
- value to be associated with the specified key- Returns:
- the previous values associated with key, or empty
List
if there was no mapping for key.
-
computeIfAbsent
Description copied from interface:Parameters
If the specified key is not already associated with a value computes new association using the given function and returns emptyList
, else returns the current value (optional operation).- Specified by:
computeIfAbsent
in interfaceParameters
- Parameters:
key
- key with which the specified value is to be associatedvalues
- value to be associated with the specified key- Returns:
- the current (potentially computed) values associated with key,
or empty
List
if function returnsnull
-
computeSingleIfAbsent
Description copied from interface:Parameters
If the specified key is not already associated with a value computes new association using the given function and returns emptyList
, else returns the current value (optional operation).- Specified by:
computeSingleIfAbsent
in interfaceParameters
- Parameters:
key
- a key with which the specified value is to be associatedvalue
- a single value to be associated with the specified key- Returns:
- the current (potentially computed) values associated with key,
or empty
List
if function returnsnull
-
putAll
Description copied from interface:Parameters
Copies all of the mappings from the specifiedparameters
to this instance replacing values of existing associations (optional operation).- Specified by:
putAll
in interfaceParameters
- Parameters:
parameters
- to copy.- Returns:
- this instance of
Parameters
-
add
Description copied from interface:Parameters
Adds specified values to association with the specified key (optional operation). If parameters doesn't contains mapping, new mapping is created.- Specified by:
add
in interfaceParameters
- Parameters:
key
- key with which the specified value is to be associatedvalues
- value to be add to association with the specified key- Returns:
- this instance of
Parameters
-
add
Description copied from interface:Parameters
Adds specified values to association with the specified key (optional operation). If parameters doesn't contains mapping, new mapping is created.- Specified by:
add
in interfaceParameters
- Parameters:
key
- key with which the specified value is to be associatedvalues
- value to be add to association with the specified key. Ifnull
then noting will be add.- Returns:
- this instance of
Parameters
-
addAll
Description copied from interface:Parameters
Copies all of the mappings from the specifiedparameters
to this instance adding values to existing associations (optional operation).- Specified by:
addAll
in interfaceParameters
- Parameters:
parameters
- to copy.- Returns:
- this instance of
Parameters
-
remove
Description copied from interface:Parameters
Removes the mapping for a key if it is present (optional operation).- Specified by:
remove
in interfaceParameters
- Parameters:
key
- key whose mapping is to be removed.- Returns:
- the previous value associated with key, or empty
List
.
-
toMap
Description copied from interface:Parameters
Returns a copy of parameters as a Map. This interface should only be used when it is required to iterate over the entire set of parameters.- Specified by:
toMap
in interfaceParameters
- Returns:
- the
Map
-
toString
-
equals
-
hashCode
public int hashCode()
-