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 Details

  • Method Details

    • getTypeVariables

      default Map<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 the Map type two keys will be present called 'K' and 'V' with the actual types of the key and value.
      Specified by:
      getTypeVariables in interface TypeVariableResolver
      Returns:
      A map of type variables
    • getLocale

      default Locale getLocale()
      Returns:
      The locale to use
    • getCharset

      default 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(Map<String,Argument<?>> typeVariables)
      Create a simple ConversionContext 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 simple ConversionContext 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(Class<T> argument)
      Create a simple ConversionContext 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 Locale locale)
      Create a simple ConversionContext 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
      locale - The locale
      Returns:
      The conversion context
    • of

      static <T> ArgumentConversionContext<T> of(Argument<T> argument, @Nullable Locale locale, @Nullable Charset charset)
      Create a simple ConversionContext 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
      locale - The locale
      charset - The charset
      Returns:
      The conversion context