Package io.micronaut.core.convert.value
Interface ConvertibleMultiValues<V>
- Type Parameters:
V
- The generic value
- All Superinterfaces:
ConversionServiceProvider
,ConvertibleValues<List<V>>
,Iterable<Map.Entry<String,
,List<V>>> ValueResolver<CharSequence>
- All Known Subinterfaces:
Headers
,HttpHeaders
,HttpParameters
,MessageHeaders
,MutableConvertibleMultiValues<V>
,MutableHeaders
,MutableHttpHeaders
,MutableHttpParameters
- All Known Implementing Classes:
CaseInsensitiveMutableHttpHeaders
,ConvertibleMultiValuesMap
,HttpHeadersAdapter
,MutableConvertibleMultiValuesMap
,NettyHttpHeaders
,NettyHttpParameters
,SimpleHttpHeaders
,SimpleHttpParameters
Specialization of
ConvertibleValues
where each name has multiple possible values.- Since:
- 1.0
- Author:
- Graeme Rocher
-
Field Summary
Fields inherited from interface io.micronaut.core.convert.value.ConvertibleValues
EMPTY
-
Method Summary
Modifier and TypeMethodDescriptionstatic <V> ConvertibleMultiValues<V>
empty()
An emptyConvertibleValues
.default void
forEach
(BiConsumer<String, List<V>> action) Performs the given action for each value.default void
forEachValue
(BiConsumer<String, V> action) Performs the given action for each header.get
(CharSequence name) Get a value without applying any conversion.getAll
(CharSequence name) Get all the values for the given name without applying conversion.getFirst
(CharSequence name) Get the first value of the given header.default <T> Optional<T>
getFirst
(CharSequence name, ArgumentConversionContext<T> conversionContext) Find a header and convert it to the given type.default <T> Optional<T>
getFirst
(CharSequence name, Argument<T> requiredType) Find a header and convert it to the given type.default <T> Optional<T>
getFirst
(CharSequence name, Class<T> requiredType) Find a header and convert it to the given type.default <T> T
getFirst
(CharSequence name, Class<T> requiredType, T defaultValue) Find a header and convert it to the given type.default boolean
isEmpty()
iterator()
static <T> ConvertibleMultiValues<T>
of
(Map<CharSequence, List<T>> values) Creates a newOptionalValues
for the given type and values.Methods inherited from interface io.micronaut.core.convert.value.ConvertibleValues
asMap, asMap, asProperties, contains, getConversionService, getValue, getValueType, names, subMap, subMap, subMap, values
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface io.micronaut.core.value.ValueResolver
get, get, get, get
-
Method Details
-
getAll
Get all the values for the given name without applying conversion.- Parameters:
name
- The header name- Returns:
- All the values
-
get
Get a value without applying any conversion.- Parameters:
name
- The name of the value- Returns:
- The raw value or null
- See Also:
-
isEmpty
default boolean isEmpty()- Specified by:
isEmpty
in interfaceConvertibleValues<V>
- Returns:
- Whether these values are empty
-
forEachValue
Performs the given action for each header. Note that in the case where multiple values exist for the same header then the consumer will be invoked multiple times for the same key.- Parameters:
action
- The action to be performed for each entry- Throws:
NullPointerException
- if the specified action is null- Since:
- 1.0
-
forEach
Description copied from interface:ConvertibleValues
Performs the given action for each value. Note that in the case where multiple values exist for the same header then the consumer will be invoked multiple times for the same key.- Specified by:
forEach
in interfaceConvertibleValues<V>
- Parameters:
action
- The action to be performed for each entry
-
iterator
-
getFirst
Get the first value of the given header.- Parameters:
name
- The header name- Returns:
- The first value or null if it is present
-
getFirst
Find a header and convert it to the given type.- Type Parameters:
T
- The generic type- Parameters:
name
- The name of the headerrequiredType
- The required type- Returns:
- If the header is presented and can be converted an optional of the value otherwise
Optional.empty()
-
getFirst
Find a header and convert it to the given type.- Type Parameters:
T
- The generic type- Parameters:
name
- The name of the headerrequiredType
- The required type- Returns:
- If the header is presented and can be converted an optional of the value otherwise
Optional.empty()
-
getFirst
Find a header and convert it to the given type.- Type Parameters:
T
- The generic type- Parameters:
name
- The name of the headerconversionContext
- The conversion context- Returns:
- If the header is presented and can be converted an optional of the value otherwise
Optional.empty()
-
getFirst
Find a header and convert it to the given type.- Type Parameters:
T
- The generic type- Parameters:
name
- The name of the headerrequiredType
- The required typedefaultValue
- The default value- Returns:
- The first value of the default supplied value if it is present
-
of
Creates a newOptionalValues
for the given type and values.- Type Parameters:
T
- The target generic type- Parameters:
values
- A map of values- Returns:
- The values
-
empty
An emptyConvertibleValues
.- Type Parameters:
V
- The generic type- Returns:
- The empty
ConvertibleValues
-