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

io.rtr.alchemy.service.jackson.ClassKeyDeserializer Maven / Gradle / Ivy

There is a newer version: 2.2.16
Show newest version
package io.rtr.alchemy.service.jackson;

import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.KeyDeserializer;

import java.io.IOException;

/**
 * Allows Jackson to deserialize Map keys of type Class<?>
 */
public class ClassKeyDeserializer extends KeyDeserializer {
    @Override
    public Object deserializeKey(String className, DeserializationContext context) throws IOException {
        try {
            return Class.forName(className);
        } catch (ClassNotFoundException e) {
            throw new IOException(String.format("could not find class %s", className));
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy