Java Code Examples for com.fasterxml.jackson.annotation.Nulls#SKIP
The following examples show how to use
com.fasterxml.jackson.annotation.Nulls#SKIP .
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: PrimitiveArrayDeserializers.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { Boolean unwrapSingle = findFormatFeature(ctxt, property, _valueClass, JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY); NullValueProvider nuller = null; Nulls nullStyle = findContentNullStyle(ctxt, property); if (nullStyle == Nulls.SKIP) { nuller = NullsConstantProvider.skipper(); } else if (nullStyle == Nulls.FAIL) { if (property == null) { nuller = NullsFailProvider.constructForRootValue(ctxt.constructType(_valueClass)); } else { nuller = NullsFailProvider.constructForProperty(property); } } if ((unwrapSingle == _unwrapSingle) && (nuller == _nuller)) { return this; } return withResolved(nuller, unwrapSingle); }
Example 2
Source File: StdDeserializer.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Method called to find {@link NullValueProvider} for a contents of a structured * primary property (Collection, Map, array), using * "content nulls" setting. If no provider found (not defined), * will return given value deserializer (which is a null value provider itself). * * @since 2.9 */ protected NullValueProvider findContentNullProvider(DeserializationContext ctxt, BeanProperty prop, JsonDeserializer<?> valueDeser) throws JsonMappingException { final Nulls nulls = findContentNullStyle(ctxt, prop); if (nulls == Nulls.SKIP) { return NullsConstantProvider.skipper(); } NullValueProvider prov = _findNullProvider(ctxt, prop, nulls, valueDeser); if (prov != null) { return prov; } return valueDeser; }
Example 3
Source File: StdDeserializer.java From lams with GNU General Public License v2.0 | 4 votes |
protected final NullValueProvider _findNullProvider(DeserializationContext ctxt, BeanProperty prop, Nulls nulls, JsonDeserializer<?> valueDeser) throws JsonMappingException { if (nulls == Nulls.FAIL) { if (prop == null) { return NullsFailProvider.constructForRootValue(ctxt.constructType(valueDeser.handledType())); } return NullsFailProvider.constructForProperty(prop); } if (nulls == Nulls.AS_EMPTY) { // cannot deal with empty values if there is no value deserializer that // can indicate what "empty value" is: if (valueDeser == null) { return null; } // Let's first do some sanity checking... // NOTE: although we could use `ValueInstantiator.Gettable` in general, // let's not since that would prevent being able to use custom impls: if (valueDeser instanceof BeanDeserializerBase) { ValueInstantiator vi = ((BeanDeserializerBase) valueDeser).getValueInstantiator(); if (!vi.canCreateUsingDefault()) { final JavaType type = prop.getType(); ctxt.reportBadDefinition(type, String.format("Cannot create empty instance of %s, no default Creator", type)); } } // Second: can with pre-fetch value? { AccessPattern access = valueDeser.getEmptyAccessPattern(); if (access == AccessPattern.ALWAYS_NULL) { return NullsConstantProvider.nuller(); } if (access == AccessPattern.CONSTANT) { return NullsConstantProvider.forValue(valueDeser.getEmptyValue(ctxt)); } } return new NullsAsEmptyProvider(valueDeser); } if (nulls == Nulls.SKIP) { return NullsConstantProvider.skipper(); } return null; }
Example 4
Source File: NullConversionsSkipTest.java From jackson-modules-base with Apache License 2.0 | 4 votes |
@JsonSetter(nulls=Nulls.SKIP) public void setNoNulls(String v) { _noNulls = v; }