/** Helper method that encapsulates logic of retrieving and caching required serializer. */ protected final JsonSerializer<Object> _findCachedSerializer( SerializerProvider provider, Class<?> type) throws JsonMappingException { JsonSerializer<Object> ser = _dynamicSerializers.serializerFor(type); if (ser == null) { ser = _findSerializer(provider, type, _property); if (_unwrapper != null) { ser = ser.unwrappingSerializer(_unwrapper); } _dynamicSerializers = _dynamicSerializers.newWith(type, ser); } return ser; }
@Override public JsonSerializer<Optional<?>> unwrappingSerializer(NameTransformer transformer) { JsonSerializer<Object> ser = _valueSerializer; if (ser != null) { ser = ser.unwrappingSerializer(transformer); } NameTransformer unwrapper = (_unwrapper == null) ? transformer : NameTransformer.chainedTransformer(transformer, _unwrapper); return withResolved(_property, _valueTypeSerializer, ser, unwrapper, _contentInclusion); }
@Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { JsonSerializer<?> ser = _valueSerializer; if (ser == null) { // 28-Sep-2015, tatu: as per [datatype-guava#83] need to ensure we don't // accidentally drop parameterization ser = _findSerializer(visitor.getProvider(), _referredType, _property); if (_unwrapper != null) { ser = ser.unwrappingSerializer(_unwrapper); } } ser.acceptJsonFormatVisitor(visitor, _referredType); }
// need to override as we must get unwrapping instance... @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; }