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
Modifier and TypeFieldDescriptionstatic final ArgumentConversionContext<Boolean>
Constant for Boolean argument.static final ConversionContext
The 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 Charset
default Locale
In 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 simpleConversionContext
for the given generic type variables.static <T> ArgumentConversionContext
Create a simpleConversionContext
for the given generic type variables.static <T> ArgumentConversionContext<T>
Create a simpleConversionContext
for the given generic type variables.static <T> ArgumentConversionContext<T>
Create a simpleConversionContext
for the given generic type variables.static ConversionContext
Create a simpleConversionContext
for 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, synthesizeDeclaredAnnotationsByType
Methods inherited from interface io.micronaut.core.annotation.AnnotationSource
getAnnotation, getAnnotation, getDeclaredAnnotation, getDeclaredAnnotation, isAnnotationPresent, isDeclaredAnnotationPresent, synthesize, synthesizeDeclared
Methods inherited from interface io.micronaut.core.convert.ErrorsContext
getLastError, hasErrors, iterator, reject, reject
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods 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 theMap
type two keys will be present called 'K' and 'V' with the actual types of the key and value.- Specified by:
getTypeVariables
in 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 simpleConversionContext
for the given generic type variables.- Parameters:
typeVariables
- The type variables- Returns:
- The conversion context
-
of
Create a new simpleConversionContext
for 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
ImmutableArgumentConversionContext
for this case.- Type Parameters:
T
- type Generic- Parameters:
argument
- The argument- Returns:
- The conversion context
-
of
Create a simpleConversionContext
for 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
ImmutableArgumentConversionContext
for this case.- Type Parameters:
T
- type Generic- Parameters:
argument
- The argument- Returns:
- The conversion context
-
of
Create a simpleConversionContext
for 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
ImmutableArgumentConversionContext
for 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 simpleConversionContext
for 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
ImmutableArgumentConversionContext
for this case.- Type Parameters:
T
- type Generic- Parameters:
argument
- The argumentlocale
- The localecharset
- The charset- Returns:
- The conversion context
-