Java Code Examples for com.fasterxml.jackson.databind.type.ReferenceType#getContentType()

The following examples show how to use com.fasterxml.jackson.databind.type.ReferenceType#getContentType() . 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: BeanSerializerFactory.java    From bistoury with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @since 2.7
 */
public JsonSerializer<?> findReferenceSerializer(SerializerProvider prov, ReferenceType refType,
                                                 BeanDescription beanDesc, boolean staticTyping)
        throws JsonMappingException
{
    JavaType contentType = refType.getContentType();
    TypeSerializer contentTypeSerializer = contentType.getTypeHandler();
    final SerializationConfig config = prov.getConfig();
    if (contentTypeSerializer == null) {
        contentTypeSerializer = createTypeSerializer(config, contentType);
    }
    JsonSerializer<Object> contentSerializer = contentType.getValueHandler();
    for (Serializers serializers : customSerializers()) {
        JsonSerializer<?> ser = serializers.findReferenceSerializer(config, refType, beanDesc,
                contentTypeSerializer, contentSerializer);
        if (ser != null) {
            return ser;
        }
    }
    if (refType.isTypeOrSubTypeOf(AtomicReference.class)) {
        return new AtomicReferenceSerializer(refType, staticTyping,
                contentTypeSerializer, contentSerializer);
    }
    return null;
}
 
Example 2
Source File: VavrSerializers.java    From vavr-jackson with Apache License 2.0 5 votes vote down vote up
@Override
public JsonSerializer<?> findReferenceSerializer(SerializationConfig config,
                                                 ReferenceType type, BeanDescription beanDesc,
                                                 TypeSerializer contentTypeSerializer, JsonSerializer<Object> contentValueSerializer) {
    Class<?> raw = type.getRawClass();
    if (Lazy.class.isAssignableFrom(raw)) {
        return new LazySerializer(type, type.getContentType(), contentTypeSerializer, contentValueSerializer);
    }
    if (Option.class.isAssignableFrom(raw)) {
        return new OptionSerializer(type, type.getContentType(), contentTypeSerializer, contentValueSerializer, settings.useOptionInPlainFormat());
    }
    return super.findReferenceSerializer(config, type, beanDesc, contentTypeSerializer, contentValueSerializer);
}
 
Example 3
Source File: VavrDeserializers.java    From vavr-jackson with Apache License 2.0 5 votes vote down vote up
@Override
public JsonDeserializer<?> findReferenceDeserializer(ReferenceType type,
                                                     DeserializationConfig config, BeanDescription beanDesc,
                                                     TypeDeserializer contentTypeDeserializer, JsonDeserializer<?> contentDeserializer)
        throws JsonMappingException {
    Class<?> raw = type.getRawClass();
    if (raw == Lazy.class) {
        return new LazyDeserializer(type, type.getContentType(), contentTypeDeserializer, contentDeserializer);
    }
    if (raw == Option.class) {
        return new OptionDeserializer(type, type.getContentType(), contentTypeDeserializer, contentDeserializer, settings.useOptionInPlainFormat());
    }
    return super.findReferenceDeserializer(type, config, beanDesc, contentTypeDeserializer, contentDeserializer);
}