Class StringMappedEnumTypeAdapter<T extends Enum<T>>

java.lang.Object
com.google.gson.TypeAdapter<T>
io.datarouter.gson.typeadapter.StringMappedEnumTypeAdapter<T>

public class StringMappedEnumTypeAdapter<T extends Enum<T>> extends com.google.gson.TypeAdapter<T>
  • Method Details

    • required

      public static final <T extends Enum<T>> StringMappedEnumTypeAdapter<T> required(io.datarouter.enums.MappedEnum<T,String> mappedEnum)
      When deserializing, throw an exception if the value is not found.
    • optional

      public static final <T extends Enum<T>> StringMappedEnumTypeAdapter<T> optional(io.datarouter.enums.MappedEnum<T,String> mappedEnum, T replacement)
      When deserializing, return the replacement if the value is not found.
    • optionalWithLogging

      public static final <T extends Enum<T>> StringMappedEnumTypeAdapter<T> optionalWithLogging(io.datarouter.enums.MappedEnum<T,String> mappedEnum, T replacement)
      When deserializing, return the replacement if the value is not found. Log the replacement.
    • write

      public void write(com.google.gson.stream.JsonWriter out, T value) throws IOException
      Specified by:
      write in class com.google.gson.TypeAdapter<T extends Enum<T>>
      Throws:
      IOException
    • read

      public T read(com.google.gson.stream.JsonReader in) throws IOException
      Specified by:
      read in class com.google.gson.TypeAdapter<T extends Enum<T>>
      Throws:
      IOException