public JsonSerializer createContextual()

in src/main/java/com/epam/eco/commons/kafka/serde/jackson/ConsumerRecordJsonSerializer.java [50:69]


    public JsonSerializer<?> createContextual(
            SerializerProvider prov, BeanProperty property) throws JsonMappingException {
        ConsumerRecordJsonSerializer serializer = new ConsumerRecordJsonSerializer();
        if (property == null) {
            return serializer;
        }
        JavaType recordType = traverseByContentTypes(property.getType(), ConsumerRecord.class);
        if (recordType == null) {
            prov.reportBadDefinition(
                    property.getType(),
                    String.format(
                            "Can't identify any type parts which are associated with '%s' class",
                            ConsumerRecord.class.getName()));
        }
        if (recordType.hasGenericTypes()) {
            serializer.keyType = recordType.containedType(0);
            serializer.valueType = recordType.containedType(1);
        }
        return serializer;
    }