/** * @since 2.8 */ public final JsonInclude.Value getDefaultPropertyInclusion(Class<?> baseType) { return _config.getDefaultPropertyInclusion(); }
/** * @deprecated Since 2.7 use {@link #getDefaultPropertyInclusion} instead */ @Deprecated public JsonInclude.Include getSerializationInclusion() { JsonInclude.Include incl = getDefaultPropertyInclusion().getValueInclusion(); return (incl == JsonInclude.Include.USE_DEFAULTS) ? JsonInclude.Include.ALWAYS : incl; }
JsonInclude.Value inclV = beanDesc.findPropertyInclusion(config.getDefaultPropertyInclusion()); inclV = config.getDefaultPropertyInclusion(configType, inclV); JsonInclude.Value valueIncl = config.getDefaultPropertyInclusion(contentType.getRawClass(), null);
public PropertyBuilder(SerializationConfig config, BeanDescription beanDesc) { _config = config; _beanDesc = beanDesc; // 08-Sep-2016, tatu: This gets tricky, with 3 levels of definitions: // (a) global default inclusion // (b) per-type default inclusion (from annotation or config overrides; // config override having precedence) // (c) per-property override (from annotation on specific property or // config overrides per type of property; // annotation having precedence) // // and not only requiring merging, but also considering special handling // for NON_DEFAULT in case of (b) (vs (a) or (c)) JsonInclude.Value inclPerType = JsonInclude.Value.merge( beanDesc.findPropertyInclusion(JsonInclude.Value.empty()), config.getDefaultPropertyInclusion(beanDesc.getBeanClass(), JsonInclude.Value.empty())); _defaultInclusion = JsonInclude.Value.merge(config.getDefaultPropertyInclusion(), inclPerType); _useRealPropertyDefaults = inclPerType.getValueInclusion() == JsonInclude.Include.NON_DEFAULT; _annotationIntrospector = _config.getAnnotationIntrospector(); }
/** * @since 2.8 */ public final JsonInclude.Value getDefaultPropertyInclusion(Class<?> baseType) { return _config.getDefaultPropertyInclusion(); }
/** * @since 2.8 */ public final JsonInclude.Value getDefaultPropertyInclusion(Class<?> baseType) { return _config.getDefaultPropertyInclusion(); }
/** * @deprecated Since 2.7 use {@link #getDefaultPropertyInclusion} instead */ @Deprecated public JsonInclude.Include getSerializationInclusion() { JsonInclude.Include incl = getDefaultPropertyInclusion().getValueInclusion(); return (incl == JsonInclude.Include.USE_DEFAULTS) ? JsonInclude.Include.ALWAYS : incl; }
void writeField(JsonGenerator generator, SerializerProvider provider, String name, String value) throws IOException { switch (provider.getConfig().getDefaultPropertyInclusion().getValueInclusion()) { case NON_NULL: case NON_ABSENT: if (value == null) return; break; case NON_EMPTY: if (value == null || value.isEmpty()) return; break; default: case ALWAYS: // Allow. break; } generator.writeStringField(name, value); } }
void writeField(JsonGenerator generator, SerializerProvider provider, String name, String value) throws IOException { switch (provider.getConfig().getDefaultPropertyInclusion().getValueInclusion()) { case NON_NULL: case NON_ABSENT: if (value == null) return; break; case NON_EMPTY: if (value == null || value.isEmpty()) return; break; default: case ALWAYS: // Allow. break; } generator.writeStringField(name, value); } }
static boolean mustIncludeNull(SerializationConfig config, Class<? extends Enumerable> enumerableType) { try { // getDefaultPropertyInclusion exists since Jackson 2.7 JsonInclude.Value inclusion = config.getDefaultPropertyInclusion(enumerableType); if (inclusion != null) return !SKIP_NULL_INCLUSIONS.contains(inclusion.getValueInclusion().name()); } catch (LinkageError le) { LOGGER.log(Level.FINEST, "SerializationConfig.getDefaultPropertyInclusion() unavailable. Using Jackson < 2.7?", le); } try { JsonInclude.Include inclusion = config.getSerializationInclusion(); if (inclusion != null) return !SKIP_NULL_INCLUSIONS.contains(inclusion.name()); } catch (LinkageError le) { LOGGER.log(Level.FINEST, "SerializationConfig.getSerializationInclusion() unavailable. Deprecation removed?", le); } return true; }
@Override public void serialize( Key value, JsonGenerator jgen, SerializerProvider provider ) throws IOException { if ( value != null || Include.NON_NULL != provider.getConfig().getDefaultPropertyInclusion().getValueInclusion() ) { StringWriter writer = new StringWriter(); JsonGenerator jsonGenerator = jgen.getCodec().getFactory().createGenerator( writer ); jgen.getCodec().writeValue( jsonGenerator, value ); jsonGenerator.close(); jgen.writeFieldName( writer.toString() ); } } }
@Override public void serialize( Ref ref, JsonGenerator jgen, SerializerProvider provider ) throws IOException { jgen.writeStartObject(); boolean includeNull = Include.NON_NULL != provider.getConfig().getDefaultPropertyInclusion().getValueInclusion(); if ( ref.key() != null || includeNull ) { jgen.writeObjectField( RefConstant.KEY, ref.key() ); } if ( ref.getValue() != null || includeNull ) { jgen.writeObjectField( RefConstant.VALUE, ref.getValue() ); } jgen.writeEndObject(); }
@Override public void serialize( Key value, JsonGenerator jgen, SerializerProvider provider ) throws IOException { jgen.writeStartObject(); boolean includeNull = Include.NON_NULL != provider.getConfig().getDefaultPropertyInclusion().getValueInclusion(); if ( value.getParent() != null || includeNull ) { jgen.writeObjectField( RawKeyConstant.PARENT, value.getParent() ); } if ( value.getKind() != null || includeNull ) { jgen.writeStringField( RawKeyConstant.KIND, value.getKind() ); } jgen.writeNumberField( RawKeyConstant.ID, value.getId() ); if ( value.getName() != null || includeNull ) { jgen.writeStringField( RawKeyConstant.NAME, value.getName() ); } jgen.writeEndObject(); }
JsonInclude.Value inclV = beanDesc.findPropertyInclusion(config.getDefaultPropertyInclusion());
JsonInclude.Value inclV = beanDesc.findPropertyInclusion(config.getDefaultPropertyInclusion()); inclV = config.getDefaultPropertyInclusion(configType, inclV); JsonInclude.Value valueIncl = config.getDefaultPropertyInclusion(contentType.getRawClass(), null);
public PropertyBuilder(SerializationConfig config, BeanDescription beanDesc) { _config = config; _beanDesc = beanDesc; // 08-Sep-2016, tatu: This gets tricky, with 3 levels of definitions: // (a) global default inclusion // (b) per-type default inclusion (from annotation or config overrides; // latter having precedence // Cc) per-property override // // and not only requiring merging, but also considering special handling // for NON_DEFAULT in case of (b) (vs (a) or (c)) JsonInclude.Value inclPerType = JsonInclude.Value.merge( beanDesc.findPropertyInclusion(JsonInclude.Value.empty()), config.getDefaultPropertyInclusion(beanDesc.getBeanClass(), JsonInclude.Value.empty())); _defaultInclusion = JsonInclude.Value.merge(config.getDefaultPropertyInclusion(), inclPerType); _useRealPropertyDefaults = inclPerType.getValueInclusion() == JsonInclude.Include.NON_DEFAULT; _annotationIntrospector = _config.getAnnotationIntrospector(); }
public PropertyBuilder(SerializationConfig config, BeanDescription beanDesc) { _config = config; _beanDesc = beanDesc; // 08-Sep-2016, tatu: This gets tricky, with 3 levels of definitions: // (a) global default inclusion // (b) per-type default inclusion (from annotation or config overrides; // config override having precedence) // (c) per-property override (from annotation on specific property or // config overrides per type of property; // annotation having precedence) // // and not only requiring merging, but also considering special handling // for NON_DEFAULT in case of (b) (vs (a) or (c)) JsonInclude.Value inclPerType = JsonInclude.Value.merge( beanDesc.findPropertyInclusion(JsonInclude.Value.empty()), config.getDefaultPropertyInclusion(beanDesc.getBeanClass(), JsonInclude.Value.empty())); _defaultInclusion = JsonInclude.Value.merge(config.getDefaultPropertyInclusion(), inclPerType); _useRealPropertyDefaults = inclPerType.getValueInclusion() == JsonInclude.Include.NON_DEFAULT; _annotationIntrospector = _config.getAnnotationIntrospector(); }
JsonInclude.Value inclV = _config.getDefaultPropertyInclusion(actualType.getRawClass(), _defaultInclusion);