Java Code Examples for com.fasterxml.jackson.databind.util.NameTransformer
The following examples show how to use
com.fasterxml.jackson.databind.util.NameTransformer.
These examples are extracted from open source projects.
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 Project: lams Author: lamsfoundation File: ReferenceTypeSerializer.java License: GNU General Public License v2.0 | 6 votes |
@SuppressWarnings("unchecked") protected ReferenceTypeSerializer(ReferenceTypeSerializer<?> base, BeanProperty property, TypeSerializer vts, JsonSerializer<?> valueSer, NameTransformer unwrapper, Object suppressableValue, boolean suppressNulls) { super(base); _referredType = base._referredType; _dynamicSerializers = base._dynamicSerializers; _property = property; _valueTypeSerializer = vts; _valueSerializer = (JsonSerializer<Object>) valueSer; _unwrapper = unwrapper; _suppressableValue = suppressableValue; _suppressNulls = suppressNulls; }
Example #2
Source Project: lams Author: lamsfoundation File: BeanSerializerBase.java License: GNU General Public License v2.0 | 6 votes |
private final static BeanPropertyWriter[] rename(BeanPropertyWriter[] props, NameTransformer transformer) { if (props == null || props.length == 0 || transformer == null || transformer == NameTransformer.NOP) { return props; } final int len = props.length; BeanPropertyWriter[] result = new BeanPropertyWriter[len]; for (int i = 0; i < len; ++i) { BeanPropertyWriter bpw = props[i]; if (bpw != null) { result[i] = bpw.rename(transformer); } } return result; }
Example #3
Source Project: lams Author: lamsfoundation File: UnwrappingBeanPropertyWriter.java License: GNU General Public License v2.0 | 6 votes |
@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 #4
Source Project: lams Author: lamsfoundation File: BeanDeserializer.java License: GNU General Public License v2.0 | 6 votes |
@Override public JsonDeserializer<Object> unwrappingDeserializer(NameTransformer transformer) { // bit kludgy but we don't want to accidentally change type; sub-classes // MUST override this method to support unwrapped properties... if (getClass() != BeanDeserializer.class) { return this; } // 25-Mar-2017, tatu: Not clean at all, but for [databind#383] we do need // to keep track of accidental recursion... if (_currentlyTransforming == transformer) { return this; } _currentlyTransforming = transformer; try { return new BeanDeserializer(this, transformer); } finally { _currentlyTransforming = null; } }
Example #5
Source Project: lams Author: lamsfoundation File: BeanPropertyMap.java License: GNU General Public License v2.0 | 6 votes |
/** * Mutant factory method for constructing a map where all entries use given * prefix */ public BeanPropertyMap renameAll(NameTransformer transformer) { if (transformer == null || (transformer == NameTransformer.NOP)) { return this; } // Try to retain insertion ordering as well final int len = _propsInOrder.length; ArrayList<SettableBeanProperty> newProps = new ArrayList<SettableBeanProperty>(len); for (int i = 0; i < len; ++i) { SettableBeanProperty prop = _propsInOrder[i]; // What to do with holes? For now, retain if (prop == null) { newProps.add(prop); continue; } newProps.add(_rename(prop, transformer)); } // should we try to re-index? Ordering probably changed but caller probably doesn't want changes... // 26-Feb-2017, tatu: Probably SHOULD handle renaming wrt Aliases? return new BeanPropertyMap(_caseInsensitive, newProps, _aliasDefs); }
Example #6
Source Project: lams Author: lamsfoundation File: BeanPropertyMap.java License: GNU General Public License v2.0 | 6 votes |
protected SettableBeanProperty _rename(SettableBeanProperty prop, NameTransformer xf) { if (prop == null) { return prop; } String newName = xf.transform(prop.getName()); prop = prop.withSimpleName(newName); JsonDeserializer<?> deser = prop.getValueDeserializer(); if (deser != null) { @SuppressWarnings("unchecked") JsonDeserializer<Object> newDeser = (JsonDeserializer<Object>) deser.unwrappingDeserializer(xf); if (newDeser != deser) { prop = prop.withValueDeserializer(newDeser); } } return prop; }
Example #7
Source Project: lams Author: lamsfoundation File: UnwrappedPropertyHandler.java License: GNU General Public License v2.0 | 6 votes |
public UnwrappedPropertyHandler renameAll(NameTransformer transformer) { ArrayList<SettableBeanProperty> newProps = new ArrayList<SettableBeanProperty>(_properties.size()); for (SettableBeanProperty prop : _properties) { String newName = transformer.transform(prop.getName()); prop = prop.withSimpleName(newName); JsonDeserializer<?> deser = prop.getValueDeserializer(); if (deser != null) { @SuppressWarnings("unchecked") JsonDeserializer<Object> newDeser = (JsonDeserializer<Object>) deser.unwrappingDeserializer(transformer); if (newDeser != deser) { prop = prop.withValueDeserializer(newDeser); } } newProps.add(prop); } return new UnwrappedPropertyHandler(newProps); }
Example #8
Source Project: jackson-modules-base Author: FasterXML File: SuperSonicBeanDeserializer.java License: Apache License 2.0 | 6 votes |
@Override public JsonDeserializer<Object> unwrappingDeserializer(DeserializationContext ctxt, NameTransformer transformer) { // NOTE: copied verbatim from `BeanDeserializer` if (_currentlyTransforming == transformer) { // from [databind#383] return this; } _currentlyTransforming = transformer; try { UnwrappedPropertyHandler uwHandler = _unwrappedPropertyHandler; if (uwHandler != null) { uwHandler = uwHandler.renameAll(ctxt, transformer); } return new SuperSonicBeanDeserializer(this, uwHandler, _beanProperties.renameAll(ctxt, transformer), true); } finally { _currentlyTransforming = null; } }
Example #9
Source Project: jackson-modules-base Author: FasterXML File: SuperSonicUnrolledDeserializer.java License: Apache License 2.0 | 6 votes |
@Override public JsonDeserializer<Object> unwrappingDeserializer(DeserializationContext ctxt, NameTransformer transformer) { // NOTE: copied verbatim from `BeanDeserializer` if (_currentlyTransforming == transformer) { // from [databind#383] return this; } _currentlyTransforming = transformer; try { UnwrappedPropertyHandler uwHandler = _unwrappedPropertyHandler; if (uwHandler != null) { uwHandler = uwHandler.renameAll(ctxt, transformer); } return new SuperSonicUnrolledDeserializer(this, uwHandler, _beanProperties.renameAll(ctxt, transformer), true); } finally { _currentlyTransforming = null; } }
Example #10
Source Project: lams Author: lamsfoundation File: AtomicReferenceSerializer.java License: GNU General Public License v2.0 | 5 votes |
protected AtomicReferenceSerializer(AtomicReferenceSerializer base, BeanProperty property, TypeSerializer vts, JsonSerializer<?> valueSer, NameTransformer unwrapper, Object suppressableValue, boolean suppressNulls) { super(base, property, vts, valueSer, unwrapper, suppressableValue, suppressNulls); }
Example #11
Source Project: lams Author: lamsfoundation File: AtomicReferenceSerializer.java License: GNU General Public License v2.0 | 5 votes |
@Override protected ReferenceTypeSerializer<AtomicReference<?>> withResolved(BeanProperty prop, TypeSerializer vts, JsonSerializer<?> valueSer, NameTransformer unwrapper) { return new AtomicReferenceSerializer(this, prop, vts, valueSer, unwrapper, _suppressableValue, _suppressNulls); }
Example #12
Source Project: lams Author: lamsfoundation File: ReferenceTypeSerializer.java License: GNU General Public License v2.0 | 5 votes |
@Override public JsonSerializer<T> unwrappingSerializer(NameTransformer transformer) { JsonSerializer<Object> valueSer = _valueSerializer; if (valueSer != null) { valueSer = valueSer.unwrappingSerializer(transformer); } NameTransformer unwrapper = (_unwrapper == null) ? transformer : NameTransformer.chainedTransformer(transformer, _unwrapper); if ((_valueSerializer == valueSer) && (_unwrapper == unwrapper)) { return this; } return withResolved(_property, _valueTypeSerializer, valueSer, unwrapper); }
Example #13
Source Project: lams Author: lamsfoundation File: BeanPropertyWriter.java License: GNU General Public License v2.0 | 5 votes |
public BeanPropertyWriter rename(NameTransformer transformer) { String newName = transformer.transform(_name.getValue()); if (newName.equals(_name.toString())) { return this; } return _new(PropertyName.construct(newName)); }
Example #14
Source Project: lams Author: lamsfoundation File: UnwrappingBeanPropertyWriter.java License: GNU General Public License v2.0 | 5 votes |
@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(transformer, new SerializedString(newName)); }
Example #15
Source Project: lams Author: lamsfoundation File: UnwrappingBeanPropertyWriter.java License: GNU General Public License v2.0 | 5 votes |
@Override public void assignSerializer(JsonSerializer<Object> ser) { if (ser != null) { NameTransformer t = _nameTransformer; if (ser.isUnwrappingSerializer()) { t = NameTransformer.chainedTransformer(t, ((UnwrappingBeanSerializer) ser)._nameTransformer); } ser = ser.unwrappingSerializer(t); } super.assignSerializer(ser); }
Example #16
Source Project: lams Author: lamsfoundation File: BeanAsArraySerializer.java License: GNU General Public License v2.0 | 5 votes |
@Override public JsonSerializer<Object> unwrappingSerializer(NameTransformer transformer) { /* If this gets called, we will just need delegate to the default * serializer, to "undo" as-array serialization */ return _defaultSerializer.unwrappingSerializer(transformer); }
Example #17
Source Project: lams Author: lamsfoundation File: ThrowableDeserializer.java License: GNU General Public License v2.0 | 5 votes |
@Override public JsonDeserializer<Object> unwrappingDeserializer(NameTransformer unwrapper) { if (getClass() != ThrowableDeserializer.class) { return this; } /* main thing really is to just enforce ignoring of unknown * properties; since there may be multiple unwrapped values * and properties for all may be interleaved... */ return new ThrowableDeserializer(this, unwrapper); }
Example #18
Source Project: lams Author: lamsfoundation File: BuilderBasedDeserializer.java License: GNU General Public License v2.0 | 5 votes |
@Override public JsonDeserializer<Object> unwrappingDeserializer(NameTransformer unwrapper) { /* main thing really is to just enforce ignoring of unknown * properties; since there may be multiple unwrapped values * and properties for all may be interleaved... */ return new BuilderBasedDeserializer(this, unwrapper); }
Example #19
Source Project: lams Author: lamsfoundation File: BeanAsArrayDeserializer.java License: GNU General Public License v2.0 | 5 votes |
@Override public JsonDeserializer<Object> unwrappingDeserializer(NameTransformer unwrapper) { /* We can't do much about this; could either replace _delegate * with unwrapping instance, or just replace this one. Latter seems * more sensible. */ return _delegate.unwrappingDeserializer(unwrapper); }
Example #20
Source Project: lams Author: lamsfoundation File: BeanAsArrayBuilderDeserializer.java License: GNU General Public License v2.0 | 5 votes |
@Override public JsonDeserializer<Object> unwrappingDeserializer(NameTransformer unwrapper) { /* We can't do much about this; could either replace _delegate * with unwrapping instance, or just replace this one. Latter seems * more sensible. */ return _delegate.unwrappingDeserializer(unwrapper); }
Example #21
Source Project: jackson-datatypes-collections Author: FasterXML File: GuavaOptionalSerializer.java License: Apache License 2.0 | 5 votes |
public GuavaOptionalSerializer(GuavaOptionalSerializer base, BeanProperty property, TypeSerializer vts, JsonSerializer<?> valueSer, NameTransformer unwrapper, Object suppressableValue, boolean suppressNulls) { super(base, property, vts, valueSer, unwrapper, suppressableValue, suppressNulls); }
Example #22
Source Project: jackson-datatypes-collections Author: FasterXML File: GuavaOptionalSerializer.java License: Apache License 2.0 | 5 votes |
@Override protected ReferenceTypeSerializer<Optional<?>> withResolved(BeanProperty prop, TypeSerializer vts, JsonSerializer<?> valueSer, NameTransformer unwrapper) { if ((_property == prop) && (_valueTypeSerializer == vts) && (_valueSerializer == valueSer) && (_unwrapper == unwrapper)) { return this; } return new GuavaOptionalSerializer(this, prop, vts, valueSer, unwrapper, _suppressableValue, _suppressNulls); }
Example #23
Source Project: cyclops Author: aol File: OptionSerializer.java License: Apache License 2.0 | 5 votes |
protected OptionSerializer(OptionSerializer base, BeanProperty property, TypeSerializer vts, JsonSerializer<?> valueSer, NameTransformer unwrapper, Object suppressableValue, boolean suppressNulls) { super(base, property, vts, valueSer, unwrapper, suppressableValue, suppressNulls); }
Example #24
Source Project: cyclops Author: aol File: OptionSerializer.java License: Apache License 2.0 | 5 votes |
@Override protected ReferenceTypeSerializer<Option<?>> withResolved(BeanProperty prop, TypeSerializer vts, JsonSerializer<?> valueSer, NameTransformer unwrapper) { return new OptionSerializer(this, prop, vts, valueSer, unwrapper, _suppressableValue, _suppressNulls); }
Example #25
Source Project: cyclops Author: aol File: TrampolineSerializer.java License: Apache License 2.0 | 5 votes |
protected TrampolineSerializer(TrampolineSerializer base, BeanProperty property, TypeSerializer vts, JsonSerializer<?> valueSer, NameTransformer unwrapper, Object suppressablTrampolineue, boolean suppressNulls) { super(base, property, vts, valueSer, unwrapper, suppressablTrampolineue, suppressNulls); }
Example #26
Source Project: cyclops Author: aol File: TrampolineSerializer.java License: Apache License 2.0 | 5 votes |
@Override protected ReferenceTypeSerializer<Trampoline<?>> withResolved(BeanProperty prop, TypeSerializer vts, JsonSerializer<?> valueSer, NameTransformer unwrapper) { return new TrampolineSerializer(this, prop, vts, valueSer, unwrapper, _suppressableValue, _suppressNulls); }
Example #27
Source Project: cyclops Author: aol File: ValueSerializer.java License: Apache License 2.0 | 5 votes |
protected ValueSerializer(ValueSerializer base, BeanProperty property, TypeSerializer vts, JsonSerializer<?> valueSer, NameTransformer unwrapper, Object suppressableValue, boolean suppressNulls) { super(base, property, vts, valueSer, unwrapper, suppressableValue, suppressNulls); }
Example #28
Source Project: cyclops Author: aol File: ValueSerializer.java License: Apache License 2.0 | 5 votes |
@Override protected ReferenceTypeSerializer<Value<?>> withResolved(BeanProperty prop, TypeSerializer vts, JsonSerializer<?> valueSer, NameTransformer unwrapper) { return new ValueSerializer(this, prop, vts, valueSer, unwrapper, _suppressableValue, _suppressNulls); }
Example #29
Source Project: cyclops Author: aol File: EvalSerializer.java License: Apache License 2.0 | 5 votes |
protected EvalSerializer(EvalSerializer base, BeanProperty property, TypeSerializer vts, JsonSerializer<?> valueSer, NameTransformer unwrapper, Object suppressableValue, boolean suppressNulls) { super(base, property, vts, valueSer, unwrapper, suppressableValue, suppressNulls); }
Example #30
Source Project: cyclops Author: aol File: EvalSerializer.java License: Apache License 2.0 | 5 votes |
@Override protected ReferenceTypeSerializer<Eval<?>> withResolved(BeanProperty prop, TypeSerializer vts, JsonSerializer<?> valueSer, NameTransformer unwrapper) { return new EvalSerializer(this, prop, vts, valueSer, unwrapper, _suppressableValue, _suppressNulls); }