Class EnumSerializer<E>

java.lang.Object
software.amazon.awssdk.iot.EnumSerializer<E>
Type Parameters:
E - the enumeration type the serializer should work with
All Implemented Interfaces:
com.google.gson.JsonDeserializer<E>, com.google.gson.JsonSerializer<E>

public class EnumSerializer<E> extends Object implements com.google.gson.JsonSerializer<E>, com.google.gson.JsonDeserializer<E>
Custom JSON serializer for enumerated types within IoT service models
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    deserialize(com.google.gson.JsonElement json, Type typeOfEnum, com.google.gson.JsonDeserializationContext context)
    Deserializes the JsonElement to an enum
    com.google.gson.JsonElement
    serialize(E enumValue, Type typeOfEnum, com.google.gson.JsonSerializationContext context)
    Serializes the given enum to a JsonElement

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • EnumSerializer

      public EnumSerializer()
  • Method Details

    • serialize

      public com.google.gson.JsonElement serialize(E enumValue, Type typeOfEnum, com.google.gson.JsonSerializationContext context)
      Serializes the given enum to a JsonElement
      Specified by:
      serialize in interface com.google.gson.JsonSerializer<E>
      Parameters:
      enumValue - The enum to convert
      typeOfEnum - The enum to convert type
      context - The JsonSerializationContext to use
      Returns:
      The enum as a JsonElement
    • deserialize

      public E deserialize(com.google.gson.JsonElement json, Type typeOfEnum, com.google.gson.JsonDeserializationContext context) throws com.google.gson.JsonParseException
      Deserializes the JsonElement to an enum
      Specified by:
      deserialize in interface com.google.gson.JsonDeserializer<E>
      Parameters:
      json - The json to convert
      typeOfEnum - The type of enum to convert to
      context - The JsonDeserializationContext to use
      Returns:
      The enum from the JsonElement data
      Throws:
      com.google.gson.JsonParseException