me.smecsia.gawain.jackson.GawainJacksonDeserializers Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gawain-jackson Show documentation
Show all versions of gawain-jackson Show documentation
Microframework focusing on data processing and aggregation in distributed environment
package me.smecsia.gawain.jackson;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.deser.ContextualDeserializer;
import com.fasterxml.jackson.databind.deser.Deserializers;
import com.fasterxml.jackson.databind.deser.std.*;
import com.fasterxml.jackson.databind.jsontype.TypeDeserializer;
import com.fasterxml.jackson.databind.type.ArrayType;
import jodd.util.StringUtil;
import java.io.IOException;
import java.util.Date;
import java.util.Objects;
import static com.fasterxml.jackson.core.JsonToken.START_OBJECT;
import static java.lang.Long.parseLong;
/**
* @author Ilya Sadykov
*/
class GawainJacksonDeserializers extends Deserializers.Base {
@Override
public JsonDeserializer> findBeanDeserializer(JavaType type,
DeserializationConfig config,
BeanDescription beanDesc) throws JsonMappingException {
if (Long.class.isAssignableFrom(type.getRawClass()) || (type.isPrimitive() && Long.TYPE.equals(type.getRawClass()))) {
return new GawainLongDeserializer();
}
if (type.getRawClass().equals(Date.class)) {
return new GawainDateDeserializer();
}
return super.findBeanDeserializer(type, config, beanDesc);
}
@Override
public JsonDeserializer> findArrayDeserializer(ArrayType type, DeserializationConfig config, BeanDescription beanDesc,
TypeDeserializer elementTypeDeserializer,
JsonDeserializer> elementDeserializer) throws JsonMappingException {
if (type.getContentType().getRawClass().equals(String.class)) {
return new GawainIterableDeserializer(StringArrayDeserializer.instance);
}
if (type.getContentType().isPrimitive()) {
return new GawainIterableDeserializer(PrimitiveArrayDeserializers.forType(type.getContentType().getRawClass()));
}
return super.findArrayDeserializer(type, config, beanDesc, elementTypeDeserializer, elementDeserializer);
}
static class GawainIterableDeserializer extends StdDeserializer
© 2015 - 2025 Weber Informatics LLC | Privacy Policy