Package io.micronaut.core.convert.value
Interface ConvertibleValues<V>
- Type Parameters:
V- The generic value
- All Superinterfaces:
ConversionServiceProvider,Iterable<Map.Entry<String,,V>> ValueResolver<CharSequence>
- All Known Subinterfaces:
BeanElementVisitorContext,ConvertibleMultiValues<V>,Cookies,Headers,HttpHeaders,HttpParameters,MessageHeaders,MutableConvertibleMultiValues<V>,MutableConvertibleValues<V>,MutableHeaders,MutableHttpHeaders,MutableHttpParameters,VisitorContext,WebSocketSession
- All Known Implementing Classes:
CaseInsensitiveMutableHttpHeaders,ConvertibleMultiValuesMap,ConvertibleValuesMap,GroovyVisitorContext,HttpHeadersAdapter,JavaVisitorContext,JsonNodeConvertibleValues,MutableConvertibleMultiValuesMap,MutableConvertibleValuesMap,NettyCookies,NettyHttpHeaders,NettyHttpParameters,NettyWebSocketSession,ObjectNodeConvertibleValues,SimpleCookies,SimpleHttpHeaders,SimpleHttpParameters
public interface ConvertibleValues<V>
extends ValueResolver<CharSequence>, Iterable<Map.Entry<String,V>>, ConversionServiceProvider
An interface for classes that represent a map-like structure of values that can be converted.
- Since:
- 1.0
- Author:
- Graeme Rocher
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionasMap()Return thisConvertibleValuesas a map for the given key type and value type.default <KT,VT> Map<KT, VT> Return thisConvertibleValuesas a map for the given key type and value type.default PropertiesReturn thisConvertibleValuesas aPropertiesobject returning only keys and values that can be represented as a string.default booleanWhether the given key is contained within these values.static <V> ConvertibleValues<V>empty()An emptyConvertibleValues.default voidforEach(BiConsumer<String, V> action) Performs the given action for each value.default ConversionServiceProvides the conversion service.default VgetValue(CharSequence name) Get a raw value without any conversion.default booleanisEmpty()iterator()names()static <T> ConvertibleValues<T>of(Map<? extends CharSequence, T> values) Creates a newConvertibleValuesfor the values.static <T> ConvertibleValues<T>of(Map<? extends CharSequence, T> values, ConversionService conversionService) Creates a newConvertibleValuesfor the values.subMap(String prefix, ArgumentConversionContext<V> valueType) Returns a submap for all the keys with the given prefix.Returns a submap for all the keys with the given prefix.Returns a submap for all the keys with the given prefix.values()Methods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface io.micronaut.core.value.ValueResolver
get, get, get, get
-
Field Details
-
EMPTY
-
-
Method Details
-
names
- Returns:
- The names of the values
-
values
Collection<V> values()- Returns:
- The values
-
isEmpty
default boolean isEmpty()- Returns:
- Whether these values are empty
-
getValueType
- Returns:
- The concrete type of the value
-
contains
Whether the given key is contained within these values.- Parameters:
name- The key name- Returns:
- True if it is
-
getValue
Get a raw value without any conversion.- Parameters:
name- The key name- Returns:
- True if it is
- Since:
- 2.0.0
-
forEach
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.- Parameters:
action- The action to be performed for each entry- Throws:
NullPointerException- if the specified action is null- Since:
- 1.0
-
asMap
Return thisConvertibleValuesas a map for the given key type and value type. The map represents a copy of the data held by this instance.- Returns:
- The values
-
asMap
Return thisConvertibleValuesas a map for the given key type and value type. If any entry cannot be converted to the target key/value type then the entry is simply excluded, hence the size of the map returned may not match the size of thisConvertibleValues.- Type Parameters:
KT- The key typeVT- The value type- Parameters:
keyType- The key typevalueType- The value type- Returns:
- The values with the key converted to the given key type and the value to the given value type.
-
asProperties
Return thisConvertibleValuesas aPropertiesobject returning only keys and values that can be represented as a string.- Returns:
- The values with the key converted to the given key type and the value to the given value type.
- Since:
- 1.0.3
-
subMap
Returns a submap for all the keys with the given prefix.- Parameters:
prefix- The prefixvalueType- The value type- Returns:
- The submap
-
subMap
Returns a submap for all the keys with the given prefix.- Parameters:
prefix- The prefixvalueType- The value type- Returns:
- The submap
-
subMap
Returns a submap for all the keys with the given prefix.- Parameters:
prefix- The prefixvalueType- The value type- Returns:
- The submap
-
iterator
-
of
Creates a newConvertibleValuesfor the values.- Type Parameters:
T- The target generic type- Parameters:
values- A map of values- Returns:
- The values
-
of
static <T> ConvertibleValues<T> of(Map<? extends CharSequence, T> values, ConversionService conversionService) Creates a newConvertibleValuesfor the values.- Type Parameters:
T- The target generic type- Parameters:
values- A map of valuesconversionService- The conversion service- Returns:
- The values
- Since:
- 4.0.0
-
empty
An emptyConvertibleValues.- Type Parameters:
V- The generic type- Returns:
- The empty
ConvertibleValues
-
getConversionService
Description copied from interface:ConversionServiceProviderProvides the conversion service.- Specified by:
getConversionServicein interfaceConversionServiceProvider- Returns:
- the conversion service
-