Package io.micronaut.core.convert
Interface ConversionContext
-
- All Superinterfaces:
AnnotationMetadataProvider
,AnnotationSource
,ErrorsContext
,java.lang.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 aTypeConverter
that allows more accurate conversion.- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description static ArgumentConversionContext<java.lang.Boolean>
BOOLEAN
Constant for Boolean argument.static ConversionContext
DEFAULT
The default conversion context.static ArgumentConversionContext<java.lang.Integer>
INT
Constant for Integer argument.static ArgumentConversionContext<java.util.List<java.lang.String>>
LIST_OF_STRING
Constant forList<String>
argument.static ArgumentConversionContext<java.lang.Long>
LONG
Constant for Long argument.static ArgumentConversionContext<java.util.Map>
MAP
Constant forList<String>
argument.static ArgumentConversionContext<java.lang.String>
STRING
Constant for String argument.-
Fields inherited from interface io.micronaut.core.annotation.AnnotationSource
EMPTY
-
-
Method Summary
All Methods Static Methods Instance Methods Default Methods Modifier and Type Method Description default java.nio.charset.Charset
getCharset()
default java.util.Locale
getLocale()
default java.util.Map<java.lang.String,Argument<?>>
getTypeVariables()
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>
of(Argument<T> argument)
Create a new simpleConversionContext
for the given generic type variables.static <T> ArgumentConversionContext
of(Argument<T> argument, java.util.Locale locale)
Create a simpleConversionContext
for the given generic type variables.static <T> ArgumentConversionContext<T>
of(Argument<T> argument, java.util.Locale locale, java.nio.charset.Charset charset)
Create a simpleConversionContext
for the given generic type variables.static <T> ArgumentConversionContext<T>
of(java.lang.Class<T> argument)
Create a simpleConversionContext
for the given generic type variables.static ConversionContext
of(java.util.Map<java.lang.String,Argument<?>> typeVariables)
Create a simpleConversionContext
for the given generic type variables.default <T> ArgumentConversionContext<T>
with(Argument<T> argument)
Augment this context with data for the given argument.-
Methods inherited from interface io.micronaut.core.annotation.AnnotationMetadataProvider
findAnnotation, findAnnotation, findDeclaredAnnotation, findDeclaredAnnotation, getAnnotationMetadata, 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 io.micronaut.core.type.TypeVariableResolver
getFirstTypeVariable, getTypeParameters, getTypeVariable
-
-
-
-
Field Detail
-
DEFAULT
static final ConversionContext DEFAULT
The default conversion context.
-
BOOLEAN
static final ArgumentConversionContext<java.lang.Boolean> BOOLEAN
Constant for Boolean argument.
-
INT
static final ArgumentConversionContext<java.lang.Integer> INT
Constant for Integer argument.
-
LONG
static final ArgumentConversionContext<java.lang.Long> LONG
Constant for Long argument.
-
STRING
static final ArgumentConversionContext<java.lang.String> STRING
Constant for String argument.
-
LIST_OF_STRING
static final ArgumentConversionContext<java.util.List<java.lang.String>> LIST_OF_STRING
Constant forList<String>
argument.
-
MAP
static final ArgumentConversionContext<java.util.Map> MAP
Constant forList<String>
argument.
-
-
Method Detail
-
getTypeVariables
default java.util.Map<java.lang.String,Argument<?>> 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
default java.util.Locale getLocale()
- Returns:
- The locale to use
-
getCharset
default java.nio.charset.Charset getCharset()
- Returns:
- The standard charset used in conversion
-
with
default <T> ArgumentConversionContext<T> with(Argument<T> argument)
Augment this context with data for the given argument.- Type Parameters:
T
- type Generic- Parameters:
argument
- The argument- Returns:
- The conversion context
-
of
static ConversionContext of(java.util.Map<java.lang.String,Argument<?>> typeVariables)
Create a simpleConversionContext
for the given generic type variables.- Parameters:
typeVariables
- The type variables- Returns:
- The conversion context
-
of
static <T> ArgumentConversionContext<T> of(Argument<T> argument)
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
static <T> ArgumentConversionContext<T> of(java.lang.Class<T> argument)
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
static <T> ArgumentConversionContext of(Argument<T> argument, @Nullable java.util.Locale locale)
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 java.util.Locale locale, @Nullable java.nio.charset.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
-
-