Java Code Examples for com.fasterxml.jackson.databind.SerializerProvider#constructSpecializedType()

The following examples show how to use com.fasterxml.jackson.databind.SerializerProvider#constructSpecializedType() . 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: UnwrappingBeanPropertyWriter.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected JsonSerializer<Object> _findAndAddDynamic(PropertySerializerMap map,
        Class<?> type, SerializerProvider provider) throws JsonMappingException
{
    JsonSerializer<Object> serializer;
    if (_nonTrivialBaseType != null) {
        JavaType subtype = provider.constructSpecializedType(_nonTrivialBaseType, type);
        serializer = provider.findValueSerializer(subtype, this);
    } else {
        serializer = provider.findValueSerializer(type, this);
    }
    NameTransformer t = _nameTransformer;
    if (serializer.isUnwrappingSerializer()) {
        t = NameTransformer.chainedTransformer(t, ((UnwrappingBeanSerializer) serializer)._nameTransformer);
    }
    serializer = serializer.unwrappingSerializer(t);
    
    _dynamicSerializers = _dynamicSerializers.newWith(type, serializer);
    return serializer;
}
 
Example 2
Source File: HListSerializer.java    From vavr-jackson with Apache License 2.0 6 votes vote down vote up
void write(Object val, int containedTypeIndex, JsonGenerator gen, SerializerProvider provider) throws IOException {
    if (val != null) {
        if (type.containedTypeCount() > containedTypeIndex) {
            JsonSerializer<Object> ser;
            JavaType containedType = type.containedType(containedTypeIndex);
            if (containedType != null && containedType.hasGenericTypes()) {
                JavaType st = provider.constructSpecializedType(containedType, val.getClass());
                ser = provider.findTypedValueSerializer(st, true, null);
            } else {
                ser = provider.findTypedValueSerializer(val.getClass(), true, null);
            }
            ser.serialize(val, gen, provider);
        } else {
            gen.writeObject(val);
        }
    } else {
        gen.writeNull();
    }
}
 
Example 3
Source File: TypelessCollectionSerializer.java    From spring-boot-data-geode with Apache License 2.0 4 votes vote down vote up
private JavaType constructSpecializedType(SerializerProvider serializerProvider, JavaType baseType, Class<?> subclass) {
	return serializerProvider.constructSpecializedType(baseType, subclass);
}