com.fasterxml.jackson.databind.util.NameTransformer Java Examples
The following examples show how to use
com.fasterxml.jackson.databind.util.NameTransformer.
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 |
@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: UnwrappedPropertyHandler.java From lams with 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 #3
Source File: BeanPropertyMap.java From lams with 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 #4
Source File: BeanPropertyMap.java From lams with 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 #5
Source File: BeanDeserializer.java From lams with 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 #6
Source File: SuperSonicBeanDeserializer.java From jackson-modules-base with 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 #7
Source File: SuperSonicUnrolledDeserializer.java From jackson-modules-base with 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 #8
Source File: BeanSerializerBase.java From lams with 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 #9
Source File: ReferenceTypeSerializer.java From lams with 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 #10
Source File: ValueSerializer.java From cyclops with 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 #11
Source File: DataBinderDeserializer.java From gvnix with GNU General Public License v3.0 | 5 votes |
/** * {@inheritDoc} * * Not used */ @Override public JsonDeserializer<Object> unwrappingDeserializer( NameTransformer unwrapper) { // Not used return null; }
Example #12
Source File: BeanAsArrayBuilderDeserializer.java From lams with 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 #13
Source File: BeanAsArrayDeserializer.java From lams with 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 #14
Source File: EvalSerializer.java From cyclops with 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); }
Example #15
Source File: EvalSerializer.java From cyclops with 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 #16
Source File: BuilderBasedDeserializer.java From lams with 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 #17
Source File: ThrowableDeserializer.java From lams with 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 File: GuavaOptionalSerializer.java From jackson-datatypes-collections with 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 #19
Source File: AtomicReferenceSerializer.java From lams with 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 #20
Source File: GuavaOptionalSerializer.java From jackson-datatypes-collections with 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 #21
Source File: AtomicReferenceSerializer.java From lams with 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 #22
Source File: BeanAsArraySerializer.java From lams with 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 #23
Source File: UnwrappingBeanPropertyWriter.java From lams with 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 #24
Source File: OptionSerializer.java From cyclops with 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 #25
Source File: UnwrappingBeanPropertyWriter.java From lams with 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 #26
Source File: OptionSerializer.java From cyclops with 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 #27
Source File: TrampolineSerializer.java From cyclops with 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 #28
Source File: TrampolineSerializer.java From cyclops with 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 #29
Source File: BeanPropertyWriter.java From lams with 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 #30
Source File: ReferenceTypeSerializer.java From lams with 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); }