@Override public UnwrappingBeanPropertyWriter rename(NameTransformer transformer) { String oldName = _name.getValue(); String newName = transformer.transform(oldName); // important: combine transformers: transformer = NameTransformer.chainedTransformer(transformer, _nameTransformer); return new UnwrappingBeanPropertyWriter(this, transformer, new SerializedString(newName)); }
@Override public NameTransformer findUnwrappingNameTransformer(AnnotatedMember member) { JsonUnwrapped ann = _findAnnotation(member, JsonUnwrapped.class); // if not enabled, just means annotation is not enabled; not necessarily // that unwrapping should not be done (relevant when using chained introspectors) if (ann == null || !ann.enabled()) { return null; } String prefix = ann.prefix(); String suffix = ann.suffix(); return NameTransformer.simpleTransformer(prefix, suffix); }
@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); }
// need to override as we must get unwrapping instance... @Override public void assignSerializer(JsonSerializer<Object> ser) { super.assignSerializer(ser); if (_serializer != null) { NameTransformer t = _nameTransformer; if (_serializer.isUnwrappingSerializer()) { t = NameTransformer.chainedTransformer( t, ((UnwrappingBeanSerializer) _serializer)._nameTransformer); } _serializer = _serializer.unwrappingSerializer(t); } }
// Override needed to support legacy JSON Schema generator @Override protected void _depositSchemaProperty(ObjectNode propertiesNode, JsonNode schemaNode) { JsonNode props = schemaNode.get("properties"); if (props != null) { Iterator<Entry<String, JsonNode>> it = props.fields(); while (it.hasNext()) { Entry<String, JsonNode> entry = it.next(); String name = entry.getKey(); if (_nameTransformer != null) { name = _nameTransformer.transform(name); } propertiesNode.set(name, entry.getValue()); } } }
// 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; }