public JsonDeserializer createContextual()

in src/main/java/com/epam/eco/commons/kafka/serde/jackson/ConsumerRecordJsonDeserializer.java [56:83]


    public JsonDeserializer<?> createContextual(
            DeserializationContext ctxt,
            BeanProperty property) throws JsonMappingException {
        JavaType contextType;
        if (property != null) {
            contextType = property.getType();
        } else {
            contextType = ctxt.getContextualType();
        }
        ConsumerRecordJsonDeserializer deserializer = new ConsumerRecordJsonDeserializer();
        if (contextType == null) {
            return deserializer;
        }

        JavaType recordType = traverseByContentTypes(contextType, ConsumerRecord.class);
        if (recordType == null) {
            ctxt.reportBadDefinition(
                    contextType,
                    String.format(
                            "Can't identify any type parts which are associated with '%s' class",
                            ConsumerRecord.class.getName()));
        }
        if (recordType.hasGenericTypes()) {
            deserializer.keyType = recordType.containedType(0);
            deserializer.valueType = recordType.containedType(1);
        }
        return deserializer;
    }