org.codehaus.jackson.map.module.SimpleValueInstantiators Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jackson-mapper-asl Show documentation
Show all versions of jackson-mapper-asl Show documentation
Data Mapper package is a high-performance data binding package
built on Jackson JSON processor
The newest version!
package org.codehaus.jackson.map.module;
import java.util.HashMap;
import org.codehaus.jackson.map.BeanDescription;
import org.codehaus.jackson.map.DeserializationConfig;
import org.codehaus.jackson.map.deser.ValueInstantiator;
import org.codehaus.jackson.map.deser.ValueInstantiators;
import org.codehaus.jackson.map.type.ClassKey;
public class SimpleValueInstantiators
extends ValueInstantiators.Base
{
/**
* Mappings from raw (type-erased, i.e. non-generic) types
* to matching {@link ValueInstantiator} instances.
*/
protected HashMap _classMappings;
/*
/**********************************************************
/* Life-cycle, construction and configuring
/**********************************************************
*/
public SimpleValueInstantiators()
{
_classMappings = new HashMap();
}
public SimpleValueInstantiators addValueInstantiator(Class> forType,
ValueInstantiator inst)
{
_classMappings.put(new ClassKey(forType), inst);
return this;
}
@Override
public ValueInstantiator findValueInstantiator(DeserializationConfig config,
BeanDescription beanDesc, ValueInstantiator defaultInstantiator)
{
ValueInstantiator inst = _classMappings.get(new ClassKey(beanDesc.getBeanClass()));
return (inst == null) ? defaultInstantiator : inst;
}
}