Example usage for com.fasterxml.jackson.databind DeserializationContext findContextualValueDeserializer

List of usage examples for com.fasterxml.jackson.databind DeserializationContext findContextualValueDeserializer

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind DeserializationContext findContextualValueDeserializer.

Prototype

public final JsonDeserializer<Object> findContextualValueDeserializer(JavaType paramJavaType,
            BeanProperty paramBeanProperty) 

Source Link

Usage

From source file:javaslang.jackson.datatype.deserialize.CharSeqDeserializer.java

@Override
public void resolve(DeserializationContext ctxt) throws JsonMappingException {
    deserializer = ctxt.findContextualValueDeserializer(TypeFactory.unknownType(), null);
}

From source file:javaslang.jackson.datatype.deserialize.EitherDeserializer.java

@Override
public void resolve(DeserializationContext ctxt) throws JsonMappingException {
    super.resolve(ctxt);
    stringDeserializer = ctxt.findContextualValueDeserializer(ctxt.constructType(String.class), null);
}

From source file:javaslang.jackson.datatype.deserialize.MultimapDeserializer.java

@Override
public void resolve(DeserializationContext ctxt) throws JsonMappingException {
    super.resolve(ctxt);
    JavaType containerType = CollectionType.construct(ArrayList.class, mapLikeType.getContentType());
    containerDeserializer = ctxt.findContextualValueDeserializer(containerType, null);
}

From source file:net.nullschool.grains.jackson.datatype.AbstractBasicConstCollectionDeserializer.java

@Override
public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property)
        throws JsonMappingException {

    JsonDeserializer<?> ed = elementDeserializer != null ? elementDeserializer
            : ctxt.findContextualValueDeserializer(collectionType.getContentType(), property);
    TypeDeserializer etd = elementTypeDeserializer != null ? elementTypeDeserializer.forProperty(property)
            : null;/*  w w  w .  j  a v  a2  s. c o m*/

    return withDeserializers(ed, etd);
}

From source file:javaslang.jackson.datatype.deserialize.ValueDeserializer.java

@Override
public void resolve(DeserializationContext ctxt) throws JsonMappingException {
    for (int i = 0; i < typeCount; i++) {
        if (i < javaType.containedTypeCount()) {
            deserializers.add(ctxt.findRootValueDeserializer(javaType.containedType(i)));
        } else {/*from w w  w .j  ava 2s  .  c o m*/
            deserializers.add(ctxt.findContextualValueDeserializer(TypeFactory.unknownType(), null));
        }
    }
}

From source file:net.nullschool.grains.jackson.datatype.GrainDeserializer.java

@Override
public void resolve(DeserializationContext ctxt) throws JsonMappingException {
    for (GrainProperty gp : factory.getBasisProperties().values()) {
        JacksonGrainProperty prop = new JacksonGrainProperty(gp, ctxt.getTypeFactory(), getValueClass());
        JsonDeserializer<?> deserializer = ctxt.findContextualValueDeserializer(prop.getType(), prop);

        readers.put(prop.getName(), new PropertyReader(deserializer));
    }//from   w w  w .  j a  v a  2s.  c  o m

    extValueDeserializer = ctxt.findContextualValueDeserializer(ctxt.constructType(Object.class), null);
    extArrayDeserializer = ctxt.findContextualValueDeserializer(ctxt.constructType(ConstCollection.class),
            null);
    extObjectDeserializer = ctxt.findContextualValueDeserializer(ctxt.constructType(ConstMap.class), null);
}

From source file:net.nullschool.grains.jackson.datatype.AbstractBasicConstMapDeserializer.java

@Override
public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property)
        throws JsonMappingException {

    KeyDeserializer kd = keyDeserializer != null ? keyDeserializer
            : ctxt.findKeyDeserializer(mapType.getKeyType(), property);
    JsonDeserializer<?> vd = valueDeserializer != null ? valueDeserializer
            : ctxt.findContextualValueDeserializer(mapType.getContentType(), property);
    TypeDeserializer vtd = valueTypeDeserializer != null ? valueTypeDeserializer.forProperty(property) : null;

    return withDeserializers(kd, vd, vtd);
}

From source file:org.javafunk.funk.jackson.monad.OptionDeserializer.java

/**
 * Method called to finalize setup of this deserializer, after deserializer itself has been registered. This is
 * needed to handle recursive and transitive dependencies.
 *///w w  w  .  java2s .  c  o  m
@Override
public JsonDeserializer<?> createContextual(final DeserializationContext context, final BeanProperty property)
        throws JsonMappingException {
    Option<JsonDeserializer<?>> contextualValueHandler = valueHandler
            .or(new Callable<Option<? extends JsonDeserializer<?>>>() {
                @Override
                public Option<? extends JsonDeserializer<?>> call() throws Exception {
                    return option(context.findContextualValueDeserializer(referenceType, property));
                }
            });

    Option<TypeDeserializer> contextualTypeHandler = typeHandler
            .flatMap(new UnaryFunction<TypeDeserializer, Option<? extends TypeDeserializer>>() {
                @Override
                public Option<? extends TypeDeserializer> call(TypeDeserializer typeDeserializer) {
                    return option(typeDeserializer.forProperty(property));
                }
            });

    if (contextualValueHandler.equals(valueHandler) && contextualTypeHandler.equals(typeHandler)) {
        return this;
    }

    return new OptionDeserializer(referenceType, contextualTypeHandler, contextualValueHandler);
}