Package io.micronaut.core.convert.value
Interface ConvertibleMultiValues<V>
-
- Type Parameters:
V
- The generic value
- All Superinterfaces:
ConvertibleValues<java.util.List<V>>
,java.lang.Iterable<java.util.Map.Entry<java.lang.String,java.util.List<V>>>
,ValueResolver<java.lang.CharSequence>
- All Known Subinterfaces:
Headers
,MutableConvertibleMultiValues<V>
,MutableHeaders
- All Known Implementing Classes:
ConvertibleMultiValuesMap
,MutableConvertibleMultiValuesMap
public interface ConvertibleMultiValues<V> extends ConvertibleValues<java.util.List<V>>
Specialization ofConvertibleValues
where each name has multiple possible values.- Since:
- 1.0
-
-
Field Summary
-
Fields inherited from interface io.micronaut.core.convert.value.ConvertibleValues
EMPTY
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static <V> ConvertibleMultiValues<V>
empty()
An emptyConvertibleValues
.default void
forEach(java.util.function.BiConsumer<java.lang.String,java.util.List<V>> action)
Performs the given action for each value.default void
forEachValue(java.util.function.BiConsumer<java.lang.String,V> action)
Performs the given action for each header.V
get(java.lang.CharSequence name)
Get a value without applying any conversion.java.util.List<V>
getAll(java.lang.CharSequence name)
Get all the values for the given name without applying conversion.default java.util.Optional<V>
getFirst(java.lang.CharSequence name)
Get the first value of the given header.default <T> java.util.Optional<T>
getFirst(java.lang.CharSequence name, ArgumentConversionContext<T> conversionContext)
Find a header and convert it to the given type.default <T> java.util.Optional<T>
getFirst(java.lang.CharSequence name, Argument<T> requiredType)
Find a header and convert it to the given type.default <T> java.util.Optional<T>
getFirst(java.lang.CharSequence name, java.lang.Class<T> requiredType)
Find a header and convert it to the given type.default <T> T
getFirst(java.lang.CharSequence name, java.lang.Class<T> requiredType, T defaultValue)
Find a header and convert it to the given type.default boolean
isEmpty()
default java.util.Iterator<java.util.Map.Entry<java.lang.String,java.util.List<V>>>
iterator()
static <T> ConvertibleMultiValues<T>
of(java.util.Map<java.lang.CharSequence,java.util.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, getValue, getValueType, names, subMap, subMap, subMap, values
-
Methods inherited from interface io.micronaut.core.value.ValueResolver
get, get, get, get
-
-
-
-
Method Detail
-
getAll
java.util.List<V> getAll(java.lang.CharSequence name)
Get all the values for the given name without applying conversion.- Parameters:
name
- The header name- Returns:
- All the values
-
get
@Nullable V get(java.lang.CharSequence name)
Get a value without applying any conversion.- Parameters:
name
- The name of the value- Returns:
- The raw value or null
- See Also:
getFirst(CharSequence)
-
isEmpty
default boolean isEmpty()
- Specified by:
isEmpty
in interfaceConvertibleValues<V>
- Returns:
- Whether this values is empty
-
forEachValue
default void forEachValue(java.util.function.BiConsumer<java.lang.String,V> action)
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:
java.lang.NullPointerException
- if the specified action is null- Since:
- 1.0
-
forEach
default void forEach(java.util.function.BiConsumer<java.lang.String,java.util.List<V>> action)
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
default java.util.Iterator<java.util.Map.Entry<java.lang.String,java.util.List<V>>> iterator()
- Specified by:
iterator
in interfaceConvertibleValues<V>
- Specified by:
iterator
in interfacejava.lang.Iterable<V>
-
getFirst
default java.util.Optional<V> getFirst(java.lang.CharSequence name)
Get the first value of the given header.- Parameters:
name
- The header name- Returns:
- The first value or null if it is present
-
getFirst
default <T> java.util.Optional<T> getFirst(java.lang.CharSequence name, java.lang.Class<T> requiredType)
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
default <T> java.util.Optional<T> getFirst(java.lang.CharSequence name, Argument<T> requiredType)
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
default <T> java.util.Optional<T> getFirst(java.lang.CharSequence name, ArgumentConversionContext<T> conversionContext)
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
default <T> T getFirst(java.lang.CharSequence name, java.lang.Class<T> requiredType, T defaultValue)
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 isn't present
-
of
static <T> ConvertibleMultiValues<T> of(java.util.Map<java.lang.CharSequence,java.util.List<T>> values)
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
static <V> ConvertibleMultiValues<V> empty()
An emptyConvertibleValues
.- Type Parameters:
V
- The generic type- Returns:
- The empty
ConvertibleValues
-
-