Class GsonInterfaceSerializer<T>

java.lang.Object
it.polimi.ingsw.Common.GsonInterfaceSerializer<T>
Type Parameters:
T - effective type
All Implemented Interfaces:
com.google.gson.JsonDeserializer<T>, com.google.gson.JsonSerializer<T>

public final class GsonInterfaceSerializer<T> extends Object implements com.google.gson.JsonSerializer<T>, com.google.gson.JsonDeserializer<T>
Serializer for Gson Interfaces
  • Field Details

    • implementationClass

      private final Class<T> implementationClass
  • Constructor Details

    • GsonInterfaceSerializer

      private GsonInterfaceSerializer(Class<T> implementationClass)
  • Method Details

    • interfaceSerializer

      public static <T> GsonInterfaceSerializer<T> interfaceSerializer(Class<T> implementationClass)
      Implementation of Gson Interface Serializer
      Type Parameters:
      T - object type
      Parameters:
      implementationClass - effective type
      Returns:
      serializer
    • serialize

      public com.google.gson.JsonElement serialize(T value, 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 jsonElement, Type typeOfT, com.google.gson.JsonDeserializationContext context)
      Specified by:
      deserialize in interface com.google.gson.JsonDeserializer<T>