Class ExtraTypeAdapter<T>

java.lang.Object
com.google.gson.TypeAdapter<T>
me.bristermitten.mittenlib.files.json.ExtraTypeAdapter<T>
Type Parameters:
T - the type of the TypeAdapter
Direct Known Subclasses:
DataTreeTypeAdapter

public abstract class ExtraTypeAdapter<T> extends com.google.gson.TypeAdapter<T>
A thin wrapper over a TypeAdapter that also stores the type it is for. This is necessary for dynamic binding as Gson does not provide a way to get the type of a TypeAdapter, but requires it for registering (GsonBuilder.registerTypeAdapter(Type, Object)).
  • Constructor Details

    • ExtraTypeAdapter

      public ExtraTypeAdapter()
  • Method Details

    • of

      public static <T> ExtraTypeAdapter<T> of(Type type, com.google.gson.TypeAdapter<T> adapter)
      Creates an ExtraTypeAdapter from an existing TypeAdapter.
      Type Parameters:
      T - the type of the TypeAdapter
      Parameters:
      type - the type of the TypeAdapter
      adapter - the TypeAdapter
      Returns:
      the ExtraTypeAdapter
    • type

      public abstract Type type()
      Get the type that this ExtraTypeAdapter is for.
      Returns:
      The type that this ExtraTypeAdapter is for.