Package io.datarouter.gson.typeadapter
Class StringMappedEnumTypeAdapter<T extends Enum<T>>
java.lang.Object
com.google.gson.TypeAdapter<T>
io.datarouter.gson.typeadapter.StringMappedEnumTypeAdapter<T>
-
Method Summary
Modifier and TypeMethodDescriptionstatic final <T extends Enum<T>>
StringMappedEnumTypeAdapter<T>When deserializing, return the replacement if the value is not found.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.read(com.google.gson.stream.JsonReader in) static final <T extends Enum<T>>
StringMappedEnumTypeAdapter<T>When deserializing, throw an exception if the value is not found.voidMethods inherited from class com.google.gson.TypeAdapter
fromJson, fromJson, fromJsonTree, nullSafe, toJson, toJson, toJsonTree
-
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
- Specified by:
writein classcom.google.gson.TypeAdapter<T extends Enum<T>>- Throws:
IOException
-
read
- Specified by:
readin classcom.google.gson.TypeAdapter<T extends Enum<T>>- Throws:
IOException
-