com.fasterxml.jackson.databind.deser.ContextualKeyDeserializer Java Examples

The following examples show how to use com.fasterxml.jackson.databind.deser.ContextualKeyDeserializer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MaplikeDeserializer.java    From vavr-jackson with Apache License 2.0 6 votes vote down vote up
@Override
public JsonDeserializer<?> createContextual(DeserializationContext context, BeanProperty property) throws JsonMappingException {
    KeyDeserializer keyDeser = keyDeserializer;
    if (keyDeser == null) {
        keyDeser = context.findKeyDeserializer(mapType.getKeyType(), property);
    } else if (keyDeser instanceof ContextualKeyDeserializer) {
        keyDeser = ((ContextualKeyDeserializer) keyDeser).createContextual(context, property);
    }

    TypeDeserializer elementTypeDeser = elementTypeDeserializer;
    if (elementTypeDeser != null) {
        elementTypeDeser = elementTypeDeser.forProperty(property);
    }
    JsonDeserializer<?> elementDeser = elementDeserializer;
    if (elementDeser == null) {
        elementDeser = context.findContextualValueDeserializer(mapType.getContentType(), property);
    } else {
        elementDeser = context.handleSecondaryContextualization(elementDeser, property, mapType.getContentType());
    }
    return createDeserializer(keyDeser, elementTypeDeser, elementDeser);
}
 
Example #2
Source File: GuavaMapDeserializer.java    From jackson-datatypes-collections with Apache License 2.0 4 votes vote down vote up
/**
 * Method called to finalize setup of this deserializer,
 * after deserializer itself has been registered. This
 * is needed to handle recursive and transitive dependencies.
 */
@Override
public JsonDeserializer<?> createContextual(DeserializationContext ctxt,
        BeanProperty property) throws JsonMappingException
{
    KeyDeserializer keyDeser = _keyDeserializer;
    JsonDeserializer<?> valueDeser = _valueDeserializer;
    TypeDeserializer valueTypeDeser = _valueTypeDeserializer;

    // First: fetch and/or contextualize deserializers (key, value, value type)
    if (keyDeser == null) {
        keyDeser = ctxt.findKeyDeserializer(_containerType.getKeyType(), property);
    } else {
        if (keyDeser instanceof ContextualKeyDeserializer) {
            keyDeser = ((ContextualKeyDeserializer) keyDeser).createContextual(ctxt, property);
        }
    }
    final JavaType vt = _containerType.getContentType();
    if (valueDeser == null) {
        valueDeser = ctxt.findContextualValueDeserializer(vt, property);
    } else {
        valueDeser = ctxt.handleSecondaryContextualization(valueDeser, property, vt);
    }
    if (valueTypeDeser != null) {
        valueTypeDeser = valueTypeDeser.forProperty(property);
    }

    // Then other handlers

    NullValueProvider nuller = findContentNullProvider(ctxt, property, valueDeser);

    // !!! 08-Aug-2019, tatu: TODO: null skipping? Ignored properties?
    
    if ((_keyDeserializer == keyDeser) && (_valueDeserializer == valueDeser)
            && (_valueTypeDeserializer == valueTypeDeser)
            && (_nullProvider == nuller)
            ) {
        return this;
    }
    
    return withResolved(keyDeser, valueDeser, valueTypeDeser, nuller);
}