Class MultiValuesConverterFactory.MultiValuesToMapConverter
java.lang.Object
io.micronaut.core.convert.converters.MultiValuesConverterFactory.MultiValuesToMapConverter
- All Implemented Interfaces:
FormattingTypeConverter<ConvertibleMultiValues,
,Map, Format> TypeConverter<ConvertibleMultiValues,
Map>
- Enclosing class:
- MultiValuesConverterFactory
A converter to convert from
ConvertibleMultiValues
to an Map
.-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionconvert
(ConvertibleMultiValues object, Class<Map> targetType, ConversionContext conversionContext) Implemented convert function that checks which Format is specified inside theFormat
annotation If one is specified, it calls one of the corresponding abstract methods.retrieveDeepObjectValue
(ArgumentConversionContext<Map> conversionContext, String name, ConvertibleMultiValues<String> parameters) Method to retrieve the values from a parameter in DEEP_OBJECT format and return in desired type.retrieveMultiValue
(ArgumentConversionContext<Map> conversionContext, String name, ConvertibleMultiValues<String> parameters) Method to retrieve the values from a parameter in MULTI format and return in desired type.retrieveSeparatedValue
(ArgumentConversionContext<Map> conversionContext, String name, ConvertibleMultiValues<String> parameters, String defaultValue, Character delimiter) Method to retrieve the values from a separated parameter and return the parameter in desired type.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.core.convert.TypeConverter
convert
-
Field Details
-
conversionService
-
-
Constructor Details
-
MultiValuesToMapConverter
-
-
Method Details
-
retrieveSeparatedValue
protected Optional<Map> retrieveSeparatedValue(ArgumentConversionContext<Map> conversionContext, String name, ConvertibleMultiValues<String> parameters, String defaultValue, Character delimiter) Method to retrieve the values from a separated parameter and return the parameter in desired type.- Parameters:
conversionContext
- the conversion context of the value to which conversion is done (including type and annotations)name
- the name of the parameterparameters
- all the parameters from which the parameter of given name needs to be retrieveddefaultValue
- default valuedelimiter
- the delimiter of the values in the parameter String- Returns:
- the converted value if conversion was successful
-
retrieveMultiValue
protected Optional<Map> retrieveMultiValue(ArgumentConversionContext<Map> conversionContext, String name, ConvertibleMultiValues<String> parameters) Method to retrieve the values from a parameter in MULTI format and return in desired type.- Parameters:
conversionContext
- the conversion context of the value to which conversion is done (including type and annotations)name
- the name of the parameterparameters
- all the parameters from which the parameter of given name needs to be retrieved- Returns:
- the converted value if conversion was successful
-
retrieveDeepObjectValue
protected Optional<Map> retrieveDeepObjectValue(ArgumentConversionContext<Map> conversionContext, String name, ConvertibleMultiValues<String> parameters) Method to retrieve the values from a parameter in DEEP_OBJECT format and return in desired type.- Parameters:
conversionContext
- the conversion context of the value to which conversion is done (including type and annotations)name
- the name of the parameterparameters
- all the parameters from which the parameter of given name needs to be retrieved- Returns:
- the converted value if conversion was successful
-
convert
public Optional<Map> convert(ConvertibleMultiValues object, Class<Map> targetType, ConversionContext conversionContext) Implemented convert function that checks which Format is specified inside theFormat
annotation If one is specified, it calls one of the corresponding abstract methods. Otherwise empty optional is returned- Specified by:
convert
in interfaceTypeConverter<ConvertibleMultiValues,
T> - Parameters:
object
- The object typetargetType
- The target type being converted toconversionContext
- TheConversionContext
- Returns:
- The converted type or empty if the conversion is not possible
-
annotationType
- Specified by:
annotationType
in interfaceFormattingTypeConverter<ConvertibleMultiValues,
T, Format> - Returns:
- The annotation type for this formatter
-