Java Code Examples for com.fasterxml.jackson.annotation.JsonIgnoreProperties#Value
The following examples show how to use
com.fasterxml.jackson.annotation.JsonIgnoreProperties#Value .
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: BeanSerializerFactory.java From bistoury with GNU General Public License v3.0 | 6 votes |
/** * 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; }
Example 2
Source File: BeanSerializerFactory.java From lams with GNU General Public License v2.0 | 6 votes |
/** * 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; }
Example 3
Source File: GuavaSerializers.java From jackson-datatypes-collections with Apache License 2.0 | 6 votes |
@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; }
Example 4
Source File: AnnotationIntrospectorPair.java From lams with GNU General Public License v2.0 | 5 votes |
@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); }
Example 5
Source File: MutableConfigOverride.java From lams with GNU General Public License v2.0 | 4 votes |
public MutableConfigOverride setIgnorals(JsonIgnoreProperties.Value v) { _ignorals = v; return this; }
Example 6
Source File: BasicSerializerFactory.java From lams with GNU General Public License v2.0 | 4 votes |
/** * 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; }
Example 7
Source File: MapDeserializer.java From lams with GNU General Public License v2.0 | 4 votes |
/** * 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); }
Example 8
Source File: ConfigOverride.java From lams with GNU General Public License v2.0 | votes |
public JsonIgnoreProperties.Value getIgnorals() { return _ignorals; }