Class CoreTypes

java.lang.Object
io.avaje.json.core.CoreTypes

public final class CoreTypes extends Object
Provides core JsonAdapter for common types.

Supports Boolean, Integer, Long, Double, Float, String.

  • Constructor Details

  • Method Details

    • create

      public static <T> JsonAdapter<T> create(Type type)
      Return a core supported type adapter or null.

      Supports Boolean, Integer, Long, Double, Float, String.

      Parameters:
      type - The type to get the adapter for.
      Returns:
      The JsonAdapter for the type or null.
    • createArray

      public static <T> JsonAdapter<T> createArray(Class<?> elementType)
      Create a JsonAdapter for an Array of the given element type.
    • createArray

      public static <T> JsonAdapter<T> createArray(Class<?> elementType, JsonAdapter<Object> adapter)
      Create a JsonAdapter for an Array of the given type.
      Parameters:
      elementType - The element type of the array.
      Returns:
      The JsonAdapter for an Array of the given type.
    • byteArray

      public static JsonAdapter<byte[]> byteArray()
      Return a JsonAdapter for byte[].
    • createMap

      public static <V> JsonAdapter<Map<String,V>> createMap(JsonAdapter<V> valueAdapter)
      Create a JsonAdapter for a Map with a given adapter for the values.
      Parameters:
      valueAdapter - The JsonAdapter used for the values in the map.
      Returns:
      The JsonAdapter for the map.
    • createList

      public static <V> JsonAdapter<List<V>> createList(JsonAdapter<V> elementAdapter)
      Create a JsonAdapter for a List with a given adapter for the elements.
      Parameters:
      elementAdapter - The JsonAdapter used for the elements in the list.
      Returns:
      The JsonAdapter for the list.
    • createSet

      public static <V> JsonAdapter<Set<V>> createSet(JsonAdapter<V> elementAdapter)
      Create a JsonAdapter for a Set with a given adapter for the elements.
      Parameters:
      elementAdapter - The JsonAdapter used for the elements in the set.
      Returns:
      The JsonAdapter for the set.
    • createCoreAdapters

      Create a JsonAdapter that supports simple types including scalar types of: String, Integer, Long, Double, Boolean plus List and Map of those types.