com.fasterxml.jackson.annotation.JsonIgnoreProperties#Value ( )源码实例Demo

下面列出了com.fasterxml.jackson.annotation.JsonIgnoreProperties#Value ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: bistoury   文件: BeanSerializerFactory.java
/**
 * Overridable method that can filter out properties. Default implementation
 * checks annotations class may have.
 */
protected List<BeanPropertyWriter> filterBeanProperties(SerializationConfig config,
                                                        BeanDescription beanDesc, List<BeanPropertyWriter> props)
{
    // 01-May-2016, tatu: Which base type to use here gets tricky, since
    //   it may often make most sense to use general type for overrides,
    //   but what we have here may be more specific impl type. But for now
    //   just use it as is.
    JsonIgnoreProperties.Value ignorals = config.getDefaultPropertyIgnorals(beanDesc.getBeanClass(),
            beanDesc.getClassInfo());
    if (ignorals != null) {
        Set<String> ignored = ignorals.findIgnoredForSerialization();
        if (!ignored.isEmpty()) {
            Iterator<BeanPropertyWriter> it = props.iterator();
            while (it.hasNext()) {
                if (ignored.contains(it.next().getName())) {
                    it.remove();
                }
            }
        }
    }
    return props;
}
 
源代码2 项目: lams   文件: BeanSerializerFactory.java
/**
 * Overridable method that can filter out properties. Default implementation
 * checks annotations class may have.
 */
protected List<BeanPropertyWriter> filterBeanProperties(SerializationConfig config,
        BeanDescription beanDesc, List<BeanPropertyWriter> props)
{
    // 01-May-2016, tatu: Which base type to use here gets tricky, since
    //   it may often make most sense to use general type for overrides,
    //   but what we have here may be more specific impl type. But for now
    //   just use it as is.
    JsonIgnoreProperties.Value ignorals = config.getDefaultPropertyIgnorals(beanDesc.getBeanClass(),
            beanDesc.getClassInfo());
    if (ignorals != null) {
        Set<String> ignored = ignorals.findIgnoredForSerialization();
        if (!ignored.isEmpty()) {
            Iterator<BeanPropertyWriter> it = props.iterator();
            while (it.hasNext()) {
                if (ignored.contains(it.next().getName())) {
                    it.remove();
                }
            }
        }
    }
    return props;
}
 
@Override
public JsonSerializer<?> findMapLikeSerializer(SerializationConfig config,
        MapLikeType type, BeanDescription beanDesc, JsonFormat.Value formatOverrides,
        JsonSerializer<Object> keySerializer,
        TypeSerializer elementTypeSerializer, JsonSerializer<Object> elementValueSerializer)
{
    if (Multimap.class.isAssignableFrom(type.getRawClass())) {
        final AnnotationIntrospector intr = config.getAnnotationIntrospector();
        Object filterId = intr.findFilterId(config, (Annotated)beanDesc.getClassInfo());
        JsonIgnoreProperties.Value ignorals = config.getDefaultPropertyIgnorals(Multimap.class,
                beanDesc.getClassInfo());
        Set<String> ignored = (ignorals == null) ? null : ignorals.getIgnored();
        return new MultimapSerializer(type, beanDesc,
                keySerializer, elementTypeSerializer, elementValueSerializer, ignored, filterId);
    }
    return null;
}
 
源代码4 项目: lams   文件: AnnotationIntrospectorPair.java
@Override
public JsonIgnoreProperties.Value findPropertyIgnorals(Annotated a)
{
    JsonIgnoreProperties.Value v2 = _secondary.findPropertyIgnorals(a);
    JsonIgnoreProperties.Value v1 = _primary.findPropertyIgnorals(a);
    return (v2 == null) // shouldn't occur but
        ? v1 : v2.withOverrides(v1);
}
 
源代码5 项目: lams   文件: MutableConfigOverride.java
public MutableConfigOverride setIgnorals(JsonIgnoreProperties.Value v) {
    _ignorals = v;
    return this;
}
 
源代码6 项目: lams   文件: BasicSerializerFactory.java
/**
 * Helper method that handles configuration details when constructing serializers for
 * {@link java.util.Map} types.
 */
protected JsonSerializer<?> buildMapSerializer(SerializerProvider prov,
        MapType type, BeanDescription beanDesc,
        boolean staticTyping, JsonSerializer<Object> keySerializer,
        TypeSerializer elementTypeSerializer, JsonSerializer<Object> elementValueSerializer)
    throws JsonMappingException
{
    // [databind#467]: This is where we could allow serialization "as POJO": But! It's
    // nasty to undo, and does not apply on per-property basis. So, hardly optimal
    JsonFormat.Value format = beanDesc.findExpectedFormat(null);
    if ((format != null) && format.getShape() == JsonFormat.Shape.OBJECT) {
        return null;
    }

    JsonSerializer<?> ser = null;

    // Order of lookups:
    // 1. Custom serializers
    // 2. Annotations (@JsonValue, @JsonDeserialize)
    // 3. Defaults
    
    final SerializationConfig config = prov.getConfig();
    for (Serializers serializers : customSerializers()) { // (1) Custom
        ser = serializers.findMapSerializer(config, type, beanDesc,
                keySerializer, elementTypeSerializer, elementValueSerializer);
        if (ser != null) { break; }
    }
    if (ser == null) {
        ser = findSerializerByAnnotations(prov, type, beanDesc); // (2) Annotations
        if (ser == null) {
            Object filterId = findFilterId(config, beanDesc);
            // 01-May-2016, tatu: Which base type to use here gets tricky, since
            //   most often it ought to be `Map` or `EnumMap`, but due to abstract
            //   mapping it will more likely be concrete type like `HashMap`.
            //   So, for time being, just pass `Map.class`
            JsonIgnoreProperties.Value ignorals = config.getDefaultPropertyIgnorals(Map.class,
                    beanDesc.getClassInfo());
            Set<String> ignored = (ignorals == null) ? null
                    : ignorals.findIgnoredForSerialization();
            MapSerializer mapSer = MapSerializer.construct(ignored,
                    type, staticTyping, elementTypeSerializer,
                    keySerializer, elementValueSerializer, filterId);
            ser = _checkMapContentInclusion(prov, beanDesc, mapSer);
        }
    }
    // [databind#120]: Allow post-processing
    if (_factoryConfig.hasSerializerModifiers()) {
        for (BeanSerializerModifier mod : _factoryConfig.serializerModifiers()) {
            ser = mod.modifyMapSerializer(config, type, beanDesc, ser);
        }
    }
    return ser;
}
 
源代码7 项目: lams   文件: MapDeserializer.java
/**
 * Method called to finalize setup of this deserializer,
 * when it is known for which property deserializer is needed for.
 */
@Override
public JsonDeserializer<?> createContextual(DeserializationContext ctxt,
        BeanProperty property) throws JsonMappingException
{
    KeyDeserializer keyDeser = _keyDeserializer;
    if (keyDeser == null) {
        keyDeser = ctxt.findKeyDeserializer(_containerType.getKeyType(), property);
    } else {
        if (keyDeser instanceof ContextualKeyDeserializer) {
            keyDeser = ((ContextualKeyDeserializer) keyDeser).createContextual(ctxt, property);
        }
    }
    
    JsonDeserializer<?> valueDeser = _valueDeserializer;
    // [databind#125]: May have a content converter
    if (property != null) {
        valueDeser = findConvertingContentDeserializer(ctxt, property, valueDeser);
    }
    final JavaType vt = _containerType.getContentType();
    if (valueDeser == null) {
        valueDeser = ctxt.findContextualValueDeserializer(vt, property);
    } else { // if directly assigned, probably not yet contextual, so:
        valueDeser = ctxt.handleSecondaryContextualization(valueDeser, property, vt);
    }
    TypeDeserializer vtd = _valueTypeDeserializer;
    if (vtd != null) {
        vtd = vtd.forProperty(property);
    }
    Set<String> ignored = _ignorableProperties;
    AnnotationIntrospector intr = ctxt.getAnnotationIntrospector();
    if (_neitherNull(intr, property)) {
        AnnotatedMember member = property.getMember();
        if (member != null) {
            JsonIgnoreProperties.Value ignorals = intr.findPropertyIgnorals(member);
            if (ignorals != null) {
                Set<String> ignoresToAdd = ignorals.findIgnoredForDeserialization();
                if (!ignoresToAdd.isEmpty()) {
                    ignored = (ignored == null) ? new HashSet<String>() : new HashSet<String>(ignored);
                    for (String str : ignoresToAdd) {
                        ignored.add(str);
                    }
                }
            }
        }
    }
    return withResolved(keyDeser, vtd, valueDeser,
            findContentNullProvider(ctxt, property, valueDeser), ignored);
}
 
源代码8 项目: lams   文件: ConfigOverride.java
public JsonIgnoreProperties.Value getIgnorals() { return _ignorals; }