类com.fasterxml.jackson.databind.util.NameTransformer源码实例Demo

下面列出了怎么用com.fasterxml.jackson.databind.util.NameTransformer的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: lams   文件: ReferenceTypeSerializer.java
@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;
}
 
源代码2 项目: lams   文件: BeanSerializerBase.java
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;
}
 
源代码3 项目: lams   文件: UnwrappingBeanPropertyWriter.java
@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;
}
 
源代码4 项目: lams   文件: BeanDeserializer.java
@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; }
}
 
源代码5 项目: lams   文件: BeanPropertyMap.java
/**
 * 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);
}
 
源代码6 项目: lams   文件: BeanPropertyMap.java
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;
}
 
源代码7 项目: lams   文件: UnwrappedPropertyHandler.java
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);
}
 
@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; }
}
 
@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; }
}
 
源代码10 项目: lams   文件: AtomicReferenceSerializer.java
protected AtomicReferenceSerializer(AtomicReferenceSerializer base, BeanProperty property,
        TypeSerializer vts, JsonSerializer<?> valueSer,
        NameTransformer unwrapper,
        Object suppressableValue, boolean suppressNulls)
{
    super(base, property, vts, valueSer, unwrapper,
            suppressableValue, suppressNulls);
}
 
源代码11 项目: lams   文件: AtomicReferenceSerializer.java
@Override
protected ReferenceTypeSerializer<AtomicReference<?>> withResolved(BeanProperty prop,
        TypeSerializer vts, JsonSerializer<?> valueSer,
        NameTransformer unwrapper)
{
    return new AtomicReferenceSerializer(this, prop, vts, valueSer, unwrapper,
            _suppressableValue, _suppressNulls);
}
 
源代码12 项目: lams   文件: ReferenceTypeSerializer.java
@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);
}
 
源代码13 项目: lams   文件: BeanPropertyWriter.java
public BeanPropertyWriter rename(NameTransformer transformer) {
    String newName = transformer.transform(_name.getValue());
    if (newName.equals(_name.toString())) {
        return this;
    }
    return _new(PropertyName.construct(newName));
}
 
源代码14 项目: lams   文件: UnwrappingBeanPropertyWriter.java
@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));
}
 
源代码15 项目: lams   文件: UnwrappingBeanPropertyWriter.java
@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);
}
 
源代码16 项目: lams   文件: BeanAsArraySerializer.java
@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);
}
 
源代码17 项目: lams   文件: ThrowableDeserializer.java
@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);
}
 
源代码18 项目: lams   文件: BuilderBasedDeserializer.java
@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);
}
 
源代码19 项目: lams   文件: BeanAsArrayDeserializer.java
@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);
}
 
源代码20 项目: lams   文件: BeanAsArrayBuilderDeserializer.java
@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);
}
 
public GuavaOptionalSerializer(GuavaOptionalSerializer base, BeanProperty property,
        TypeSerializer vts, JsonSerializer<?> valueSer, NameTransformer unwrapper,
        Object suppressableValue, boolean suppressNulls)
{
    super(base, property, vts, valueSer, unwrapper,
            suppressableValue, suppressNulls);
}
 
@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);
}
 
源代码23 项目: cyclops   文件: OptionSerializer.java
protected OptionSerializer(OptionSerializer base, BeanProperty property,
                             TypeSerializer vts, JsonSerializer<?> valueSer, NameTransformer unwrapper,
                             Object suppressableValue, boolean suppressNulls)
{
  super(base, property, vts, valueSer, unwrapper,
    suppressableValue, suppressNulls);
}
 
源代码24 项目: cyclops   文件: OptionSerializer.java
@Override
protected ReferenceTypeSerializer<Option<?>> withResolved(BeanProperty prop,
                                                          TypeSerializer vts, JsonSerializer<?> valueSer,
                                                          NameTransformer unwrapper)
{
  return new OptionSerializer(this, prop, vts, valueSer, unwrapper,
    _suppressableValue, _suppressNulls);
}
 
源代码25 项目: cyclops   文件: TrampolineSerializer.java
protected TrampolineSerializer(TrampolineSerializer base, BeanProperty property,
                               TypeSerializer vts, JsonSerializer<?> valueSer, NameTransformer unwrapper,
                               Object suppressablTrampolineue, boolean suppressNulls)
{
  super(base, property, vts, valueSer, unwrapper,
    suppressablTrampolineue, suppressNulls);
}
 
源代码26 项目: cyclops   文件: TrampolineSerializer.java
@Override
protected ReferenceTypeSerializer<Trampoline<?>> withResolved(BeanProperty prop,
                                                          TypeSerializer vts, JsonSerializer<?> valueSer,
                                                          NameTransformer unwrapper)
{
  return new TrampolineSerializer(this, prop, vts, valueSer, unwrapper,
    _suppressableValue, _suppressNulls);
}
 
源代码27 项目: cyclops   文件: ValueSerializer.java
protected ValueSerializer(ValueSerializer base, BeanProperty property,
                          TypeSerializer vts, JsonSerializer<?> valueSer, NameTransformer unwrapper,
                          Object suppressableValue, boolean suppressNulls)
{
  super(base, property, vts, valueSer, unwrapper,
    suppressableValue, suppressNulls);
}
 
源代码28 项目: cyclops   文件: ValueSerializer.java
@Override
protected ReferenceTypeSerializer<Value<?>> withResolved(BeanProperty prop,
                                                          TypeSerializer vts, JsonSerializer<?> valueSer,
                                                          NameTransformer unwrapper)
{
  return new ValueSerializer(this, prop, vts, valueSer, unwrapper,
    _suppressableValue, _suppressNulls);
}
 
源代码29 项目: cyclops   文件: EvalSerializer.java
protected EvalSerializer(EvalSerializer base, BeanProperty property,
                         TypeSerializer vts, JsonSerializer<?> valueSer, NameTransformer unwrapper,
                         Object suppressableValue, boolean suppressNulls)
{
  super(base, property, vts, valueSer, unwrapper,
    suppressableValue, suppressNulls);
}
 
源代码30 项目: cyclops   文件: EvalSerializer.java
@Override
protected ReferenceTypeSerializer<Eval<?>> withResolved(BeanProperty prop,
                                                          TypeSerializer vts, JsonSerializer<?> valueSer,
                                                          NameTransformer unwrapper)
{
  return new EvalSerializer(this, prop, vts, valueSer, unwrapper,
    _suppressableValue, _suppressNulls);
}
 
 类方法
 同包方法