Class MultiValuesConverterFactory.AbstractConverterToMultiValues<T>
- java.lang.Object
-
- io.micronaut.core.convert.converters.MultiValuesConverterFactory.AbstractConverterToMultiValues<T>
-
- Type Parameters:
T
- The class from which to convert
- All Implemented Interfaces:
FormattingTypeConverter<T,ConvertibleMultiValues,Format>
,TypeConverter<T,ConvertibleMultiValues>
- Direct Known Subclasses:
MultiValuesConverterFactory.IterableToMultiValuesConverter
,MultiValuesConverterFactory.MapToMultiValuesConverter
,MultiValuesConverterFactory.ObjectToMultiValuesConverter
- Enclosing class:
- MultiValuesConverterFactory
public abstract static class MultiValuesConverterFactory.AbstractConverterToMultiValues<T> extends java.lang.Object implements FormattingTypeConverter<T,ConvertibleMultiValues,Format>
An abstract class to convert to ConvertibleMultiValues.
-
-
Field Summary
Fields Modifier and Type Field Description protected ConversionService<?>
conversionService
-
Constructor Summary
Constructors Constructor Description AbstractConverterToMultiValues(ConversionService<?> conversionService)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
addDeepObjectValues(ArgumentConversionContext<java.lang.Object> context, java.lang.String name, T object, MutableConvertibleMultiValuesMap<java.lang.String> parameters)
Method that adds given value to the parameters in A DEEP_OBJECT format.protected abstract void
addMutliValues(ArgumentConversionContext<java.lang.Object> context, java.lang.String name, T object, MutableConvertibleMultiValuesMap<java.lang.String> parameters)
Method that adds given value to the parameters in a MULTI format.protected abstract void
addSeparatedValues(ArgumentConversionContext<java.lang.Object> context, java.lang.String name, T object, MutableConvertibleMultiValuesMap<java.lang.String> parameters, java.lang.Character delimiter)
Method that adds given value to the parameters in a format separated by a delimiter.java.lang.Class<Format>
annotationType()
java.util.Optional<ConvertibleMultiValues>
convert(T object, java.lang.Class<ConvertibleMultiValues> targetType, ConversionContext conversionContext)
Converts from the given source object type to the target 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 Detail
-
conversionService
protected ConversionService<?> conversionService
-
-
Constructor Detail
-
AbstractConverterToMultiValues
public AbstractConverterToMultiValues(ConversionService<?> conversionService)
-
-
Method Detail
-
convert
public java.util.Optional<ConvertibleMultiValues> convert(T object, java.lang.Class<ConvertibleMultiValues> targetType, ConversionContext conversionContext)
Description copied from interface:TypeConverter
Converts from the given source object type to the target type. Implementers should take care to returnOptional.empty()
in case the object is not convertible by catching any necessary exceptions and failing gracefully.- Specified by:
convert
in interfaceTypeConverter<T,ConvertibleMultiValues>
- Parameters:
object
- The object typetargetType
- The target type being converted toconversionContext
- TheConversionContext
- Returns:
- The converted type or empty if the conversion is not possible
-
addSeparatedValues
protected abstract void addSeparatedValues(ArgumentConversionContext<java.lang.Object> context, java.lang.String name, T object, MutableConvertibleMultiValuesMap<java.lang.String> parameters, java.lang.Character delimiter)
Method that adds given value to the parameters in a format separated by a delimiter.- Parameters:
context
- - the context of conversion which has the source type and any present annotationsname
- - the name of the parameterobject
- - the object that we are converting fromparameters
- - the parameters to the value of additional parameter will be addeddelimiter
- - the required delimiter of the values in the parameter String
-
addMutliValues
protected abstract void addMutliValues(ArgumentConversionContext<java.lang.Object> context, java.lang.String name, T object, MutableConvertibleMultiValuesMap<java.lang.String> parameters)
Method that adds given value to the parameters in a MULTI format.- Parameters:
context
- - the context of conversion which has the source type and any present annotationsname
- - the name of the parameterobject
- - the object that we are converting fromparameters
- - the parameters to the value of additional parameter will be added
-
addDeepObjectValues
protected abstract void addDeepObjectValues(ArgumentConversionContext<java.lang.Object> context, java.lang.String name, T object, MutableConvertibleMultiValuesMap<java.lang.String> parameters)
Method that adds given value to the parameters in A DEEP_OBJECT format.- Parameters:
context
- - the context of conversion which has the source type and any present annotationsname
- - the name of the parameterobject
- - the object that we are converting fromparameters
- - the parameters to the value of additional parameter will be added
-
annotationType
public java.lang.Class<Format> annotationType()
- Specified by:
annotationType
in interfaceFormattingTypeConverter<T,ConvertibleMultiValues,Format>
- Returns:
- The annotation type for this formatter
-
-