
org.testifyproject.fasterxml.jackson.databind.module.SimpleKeyDeserializers Maven / Gradle / Ivy
package org.testifyproject.testifyproject.fasterxml.jackson.databind.module;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import org.testifyproject.testifyproject.fasterxml.jackson.databind.*;
import org.testifyproject.testifyproject.fasterxml.jackson.databind.org.testifyproject.testifyprojectser.KeyDeserializers;
import org.testifyproject.testifyproject.fasterxml.jackson.databind.type.ClassKey;
/**
* Simple implementation {@link KeyDeserializers} which allows registration of
* org.testifyproject.testifyprojectserializers based on raw (type erased class).
* It can work well for basic bean and scalar type org.testifyproject.testifyprojectserializers, but is not
* a good fit for handling generic types (like {@link Map}s and {@link Collection}s
* or array types).
*
* Unlike {@link SimpleSerializers}, this class does not currently support generic mappings;
* all mappings must be to exact org.testifyproject.testifyprojectclared org.testifyproject.testifyprojectserialization type.
*/
public class SimpleKeyDeserializers
implements KeyDeserializers, java.org.testifyproject.testifyproject.Serializable // since 2.1
{
private static final long serialVersionUID = 1L;
protected HashMap _classMappings = null;
/*
/**********************************************************
/* Life-cycle, construction and configuring
/**********************************************************
*/
public SimpleKeyDeserializers() { }
public SimpleKeyDeserializers addDeserializer(Class> forClass, KeyDeserializer org.testifyproject.testifyprojectser)
{
if (_classMappings == null) {
_classMappings = new HashMap();
}
_classMappings.put(new ClassKey(forClass), org.testifyproject.testifyprojectser);
return this;
}
/*
/**********************************************************
/* Serializers implementation
/**********************************************************
*/
@Override
public KeyDeserializer findKeyDeserializer(JavaType type,
DeserializationConfig config, BeanDescription beanDesc)
{
if (_classMappings == null) {
return null;
}
return _classMappings.get(new ClassKey(type.getRawClass()));
}
}