io.rtr.alchemy.service.jackson.ClassKeyDeserializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of alchemy-service Show documentation
Show all versions of alchemy-service Show documentation
REST service for hosting Alchemy as a service
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