Class AdapterKamiX<T>

java.lang.Object
com.kamikazejam.kamicommon.util.adapter.AdapterKamiX<T>
All Implemented Interfaces:
com.google.gson.JsonDeserializer<T>, com.google.gson.JsonSerializer<T>
Direct Known Subclasses:
AdapterKamiList, AdapterKamiMap, AdapterKamiSet, AdapterKamiTreeSet

public abstract class AdapterKamiX<T> extends Object implements com.google.gson.JsonDeserializer<T>, com.google.gson.JsonSerializer<T>
This is the abstract adapter for all "KamiCommon structures". It makes sure Def instances "handle empty as null". It makes sure we avoid infinite GSON recurse loops by recursing with supertype.
  • Constructor Details

    • AdapterKamiX

      public AdapterKamiX()
  • Method Details

    • serialize

      public com.google.gson.JsonElement serialize(T src, Type type, com.google.gson.JsonSerializationContext context)
      Specified by:
      serialize in interface com.google.gson.JsonSerializer<T>
    • deserialize

      public T deserialize(com.google.gson.JsonElement json, Type type, com.google.gson.JsonDeserializationContext context) throws com.google.gson.JsonParseException
      Specified by:
      deserialize in interface com.google.gson.JsonDeserializer<T>
      Throws:
      com.google.gson.JsonParseException
    • create

      public abstract T create(Object parent, com.google.gson.JsonElement json, Type typeOfT, com.google.gson.JsonDeserializationContext context)
    • getClazz

      public static Class<?> getClazz(@NotNull @NotNull ParameterizedType pType)
    • getSuperType

      @NotNull public static @NotNull ParameterizedType getSuperType(@NotNull @NotNull ParameterizedType pType)
    • getNewArgumentInstance

      @NotNull public static @NotNull Object getNewArgumentInstance(@NotNull @NotNull Type type, int index)
    • isEmpty

      @Contract("null -> true") public static boolean isEmpty(Object object)