Class Types

java.lang.Object
io.avaje.jsonb.Types

public class Types extends Object
Factory methods for types.
  • Method Details

    • arrayOf

      public static GenericArrayType arrayOf(Type elementType)
      Returns an array type whose elements are all instances of componentType.
    • listOf

      public static ParameterizedType listOf(Type elementType)
      Returns a Type that is a List of the given element type.
    • setOf

      public static ParameterizedType setOf(Type elementType)
      Returns a Type that is a Set of the given element type.
    • streamOf

      public static ParameterizedType streamOf(Type elementType)
      Returns a Type that is a Stream of the given element type.
    • mapOf

      public static ParameterizedType mapOf(Type valueElementType)
      Return the Type for a Map with String keys and the given value element type.
      Parameters:
      valueElementType - The type of the values in the Map.
      Returns:
      Type for a Map with String keys and the given value element type.
    • optionalOf

      public static ParameterizedType optionalOf(Type valueElementType)
      Returns a Type that is an Optional of the given element type.
    • newParameterizedType

      public static ParameterizedType newParameterizedType(Type rawType, Type... typeArguments)
      Returns a new parameterized type, applying typeArguments to rawType. Use this method if rawType is not enclosed in another type.
    • rawType

      public static Class<?> rawType(Type type)
      Return the raw type for the given potentially generic type.
    • typeArguments

      public static Type[] typeArguments(Type type)
      Return the generic type arguments expecting type to be a ParameterizedType.
    • isGenericTypeOf

      public static boolean isGenericTypeOf(Type jsonType, Class<?> adapterClass)
      Helper method to determine if the given type can be handled by an adapter