Java源码示例:com.fasterxml.jackson.databind.deser.ContextualKeyDeserializer

示例1
@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);
}
 
示例2
/**
 * 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);
}