- java.lang.Object
-
- io.helidon.common.http.ReadOnlyParameters
-
- All Implemented Interfaces:
Parameters
- Direct Known Subclasses:
ReadableBodyPartHeaders
public class ReadOnlyParameters extends Object implements Parameters
An immutable implementation ofParameters.- See Also:
Parameters
-
-
Constructor Summary
Constructors Constructor Description ReadOnlyParameters(Parameters parameters)Creates an instance from provided multi-map.ReadOnlyParameters(Map<String,List<String>> data)Creates an instance from provided multi-map.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ReadOnlyParametersadd(String key, Iterable<String> values)Adds specified values tu association with the specified key (optional operation).ReadOnlyParametersadd(String key, String... values)Adds specified values tu association with the specified key (optional operation).ReadOnlyParametersaddAll(Parameters parameters)Copies all of the mappings from the specifiedparametersto this instance adding values to existing associations (optional operation).List<String>all(String name)Returns an unmodifiable List of all of the values of the given named parameter.List<String>computeIfAbsent(String key, Function<String,Iterable<String>> values)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).List<String>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 ReadOnlyParametersempty()Returns empty and immutable singleton.Optional<String>first(String name)Returns anOptionalcontaining the first value of the given parameter (and possibly multi-valued) parameter.List<String>put(String key, Iterable<String> values)Associates specified values with the specified key (optional operation).List<String>put(String key, String... values)Associates specified values with the specified key (optional operation).ReadOnlyParametersputAll(Parameters parameters)Copies all of the mappings from the specifiedparametersto this instance replacing values of existing associations (optional operation).List<String>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).List<String>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).List<String>remove(String key)Removes the mapping for a key if it is present (optional operation).Map<String,List<String>>toMap()Returns a copy of parameters as a Map.
-
-
-
Constructor Detail
-
ReadOnlyParameters
public ReadOnlyParameters(Map<String,List<String>> data)
Creates an instance from provided multi-map.- Parameters:
data- multi-map data to copy.
-
ReadOnlyParameters
public ReadOnlyParameters(Parameters parameters)
Creates an instance from provided multi-map.- Parameters:
parameters- parameters to copy.
-
-
Method Detail
-
empty
public static ReadOnlyParameters empty()
Returns empty and immutable singleton.- Returns:
- the parameters singleton instance which is empty and immutable.
-
first
public Optional<String> first(String name)
Description copied from interface:ParametersReturns anOptionalcontaining 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:
firstin interfaceParameters- Parameters:
name- the parameter name- Returns:
- an
Optional<V>for the first named value
-
all
public List<String> all(String name)
Description copied from interface:ParametersReturns 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:
allin interfaceParameters- Parameters:
name- the parameter name- Returns:
- a
Listof values with zero or greater size
-
put
public List<String> put(String key, String... values)
Description copied from interface:ParametersAssociates specified values with the specified key (optional operation). If parameters previously contained a mapping for the key, the old values fully replaced.- Specified by:
putin 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
Listif there was no mapping for key.
-
put
public List<String> put(String key, Iterable<String> values)
Description copied from interface:ParametersAssociates specified values with the specified key (optional operation). If parameters previously contained a mapping for the key, the old values fully replaced.- Specified by:
putin interfaceParameters- Parameters:
key- key with which the specified value is to be associatedvalues- value to be associated with the specified key. Ifnullthen association will be removed.- Returns:
- the previous values associated with key, or empty
Listif there was no mapping for key.
-
putIfAbsent
public List<String> putIfAbsent(String key, String... values)
Description copied from interface:ParametersIf 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:
putIfAbsentin 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
Listif there was no mapping for key.
-
putIfAbsent
public List<String> putIfAbsent(String key, Iterable<String> values)
Description copied from interface:ParametersIf 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:
putIfAbsentin 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
Listif there was no mapping for key.
-
computeIfAbsent
public List<String> computeIfAbsent(String key, Function<String,Iterable<String>> values)
Description copied from interface:ParametersIf 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:
computeIfAbsentin 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
Listif function returnsnull
-
putAll
public ReadOnlyParameters putAll(Parameters parameters)
Description copied from interface:ParametersCopies all of the mappings from the specifiedparametersto this instance replacing values of existing associations (optional operation).- Specified by:
putAllin interfaceParameters- Parameters:
parameters- to copy.- Returns:
- this instance of
Parameters
-
add
public ReadOnlyParameters add(String key, String... values)
Description copied from interface:ParametersAdds specified values tu association with the specified key (optional operation). If parameters doesn't contains mapping, new mapping is created.- Specified by:
addin 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
public ReadOnlyParameters add(String key, Iterable<String> values)
Description copied from interface:ParametersAdds specified values tu association with the specified key (optional operation). If parameters doesn't contains mapping, new mapping is created.- Specified by:
addin interfaceParameters- Parameters:
key- key with which the specified value is to be associatedvalues- value to be add to association with the specified key. Ifnullthen noting will be add.- Returns:
- this instance of
Parameters
-
computeSingleIfAbsent
public List<String> computeSingleIfAbsent(String key, Function<String,String> value)
Description copied from interface:ParametersIf 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:
computeSingleIfAbsentin 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
Listif function returnsnull
-
addAll
public ReadOnlyParameters addAll(Parameters parameters)
Description copied from interface:ParametersCopies all of the mappings from the specifiedparametersto this instance adding values to existing associations (optional operation).- Specified by:
addAllin interfaceParameters- Parameters:
parameters- to copy.- Returns:
- this instance of
Parameters
-
remove
public List<String> remove(String key)
Description copied from interface:ParametersRemoves the mapping for a key if it is present (optional operation).- Specified by:
removein interfaceParameters- Parameters:
key- key whose mapping is to be removed.- Returns:
- the previous value associated with key, or empty
List.
-
toMap
public Map<String,List<String>> toMap()
Description copied from interface:ParametersReturns 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:
toMapin interfaceParameters- Returns:
- the
Map
-
-