Package io.micronaut.core.convert
Interface ConversionContext
- All Superinterfaces:
AnnotationMetadataProvider,AnnotationSource,ErrorsContext,Iterable<ConversionError>,TypeVariableResolver
- All Known Subinterfaces:
ArgumentConversionContext<T>,ImmutableArgumentConversionContext<T>
public interface ConversionContext
extends AnnotationMetadataProvider, TypeVariableResolver, ErrorsContext
A conversion context is a context object supplied to a
TypeConverter that allows more accurate conversion.- Since:
- 1.0
- Author:
- Graeme Rocher
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ArgumentConversionContext<Boolean>Constant for Boolean argument.static final ConversionContextThe default conversion context.static final ArgumentConversionContext<Integer>Constant for Integer argument.static final ArgumentConversionContext<List<String>>Constant forList<String>argument.static final ArgumentConversionContext<Long>Constant for Long argument.static final ArgumentConversionContext<Map>Constant forList<String>argument.static final ArgumentConversionContext<String>Constant for String argument.Fields inherited from interface io.micronaut.core.annotation.AnnotationSource
EMPTY -
Method Summary
Modifier and TypeMethodDescriptiondefault Charsetdefault LocaleIn the case where the type to be converted contains generic type arguments this map will return the concrete types of those arguments.static <T> ArgumentConversionContext<T>Create a new simpleConversionContextfor the given generic type variables.static <T> ArgumentConversionContextCreate a simpleConversionContextfor the given generic type variables.static <T> ArgumentConversionContext<T>Create a simpleConversionContextfor the given generic type variables.static <T> ArgumentConversionContext<T>Create a simpleConversionContextfor the given generic type variables.static ConversionContextCreate a simpleConversionContextfor the given generic type variables.default <T> ArgumentConversionContext<T>Augment this context with data for the given argument.Methods inherited from interface io.micronaut.core.annotation.AnnotationMetadataProvider
findAnnotation, findAnnotation, findDeclaredAnnotation, findDeclaredAnnotation, getAnnotationMetadata, getTargetAnnotationMetadata, isAnnotationPresent, isDeclaredAnnotationPresent, synthesize, synthesizeAll, synthesizeAnnotationsByType, synthesizeDeclared, synthesizeDeclared, synthesizeDeclaredAnnotationsByTypeMethods inherited from interface io.micronaut.core.annotation.AnnotationSource
getAnnotation, getAnnotation, getDeclaredAnnotation, getDeclaredAnnotation, isAnnotationPresent, isDeclaredAnnotationPresent, synthesize, synthesizeDeclaredMethods inherited from interface io.micronaut.core.convert.ErrorsContext
getLastError, hasErrors, iterator, reject, rejectMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface io.micronaut.core.type.TypeVariableResolver
getFirstTypeVariable, getTypeParameters, getTypeVariable
-
Field Details
-
DEFAULT
The default conversion context. -
BOOLEAN
Constant for Boolean argument. -
INT
Constant for Integer argument. -
LONG
Constant for Long argument. -
STRING
Constant for String argument. -
LIST_OF_STRING
Constant forList<String>argument. -
MAP
Constant forList<String>argument.
-
-
Method Details
-
getTypeVariables
In the case where the type to be converted contains generic type arguments this map will return the concrete types of those arguments. For example for theMaptype two keys will be present called 'K' and 'V' with the actual types of the key and value.- Specified by:
getTypeVariablesin interfaceTypeVariableResolver- Returns:
- A map of type variables
-
getLocale
- Returns:
- The locale to use
-
getCharset
- Returns:
- The standard charset used in conversion
-
with
Augment this context with data for the given argument.- Type Parameters:
T- type Generic- Parameters:
argument- The argument- Returns:
- The conversion context
-
of
Create a simpleConversionContextfor the given generic type variables.- Parameters:
typeVariables- The type variables- Returns:
- The conversion context
-
of
Create a new simpleConversionContextfor the given generic type variables.NOTE: The instance returned by this method is NOT thread safe and should be shared via static state or between threads. Consider using
ImmutableArgumentConversionContextfor this case.- Type Parameters:
T- type Generic- Parameters:
argument- The argument- Returns:
- The conversion context
-
of
Create a simpleConversionContextfor the given generic type variables.NOTE: The instance returned by this method is NOT thread safe and should be shared via static state or between threads. Consider using
ImmutableArgumentConversionContextfor this case.- Type Parameters:
T- type Generic- Parameters:
argument- The argument- Returns:
- The conversion context
-
of
Create a simpleConversionContextfor the given generic type variables.NOTE: The instance returned by this method is NOT thread safe and should be shared via static state or between threads. Consider using
ImmutableArgumentConversionContextfor this case.- Type Parameters:
T- type Generic- Parameters:
argument- The argumentlocale- The locale- Returns:
- The conversion context
-
of
static <T> ArgumentConversionContext<T> of(Argument<T> argument, @Nullable @Nullable Locale locale, @Nullable @Nullable Charset charset) Create a simpleConversionContextfor the given generic type variables.NOTE: The instance returned by this method is NOT thread safe and should be shared via static state or between threads. Consider using
ImmutableArgumentConversionContextfor this case.- Type Parameters:
T- type Generic- Parameters:
argument- The argumentlocale- The localecharset- The charset- Returns:
- The conversion context
-