All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ionos.go.plugin.notifier.util.CaseEnumAdapter Maven / Gradle / Ivy

There is a newer version: 0.5.9
Show newest version
package com.ionos.go.plugin.notifier.util;

import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;

public class CaseEnumAdapter implements JsonDeserializer {
    @Override
    public Enum deserialize(JsonElement json, java.lang.reflect.Type type, JsonDeserializationContext context)
            throws JsonParseException {
        try {
            if (type instanceof Class && ((Class) type).isEnum()) {
                return Enum.valueOf((Class) type, json.getAsString().toLowerCase());
            }
            return null;
        } catch (Exception e) {
            throw new JsonParseException(e);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy