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

public static class MultiValuesConverterFactory.MultiValuesToMapConverter extends Object
A converter to convert from ConvertibleMultiValues to an Map.
  • Field Details

  • Constructor Details

    • MultiValuesToMapConverter

      public MultiValuesToMapConverter(ConversionService conversionService)
  • 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 parameter
      parameters - all the parameters from which the parameter of given name needs to be retrieved
      defaultValue - default value
      delimiter - 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 parameter
      parameters - 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 parameter
      parameters - 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 the Format annotation If one is specified, it calls one of the corresponding abstract methods. Otherwise, empty optional is returned
      Specified by:
      convert in interface TypeConverter<ConvertibleMultiValues,T>
      Parameters:
      object - The object type
      targetType - The target type being converted to
      conversionContext - The ConversionContext
      Returns:
      The converted type or empty if the conversion is not possible
    • annotationType

      public Class<Format> annotationType()
      Specified by:
      annotationType in interface FormattingTypeConverter<ConvertibleMultiValues,T,Format>
      Returns:
      The annotation type for this formatter