@SuppressWarnings("deprecation") private JsonInclude.Value _refinePropertyInclusion(Annotated a, JsonInclude.Value value) { JsonSerialize ann = _findAnnotation(a, JsonSerialize.class); if (ann != null) { switch (ann.include()) { case ALWAYS: return value.withValueInclusion(JsonInclude.Include.ALWAYS); case NON_NULL: return value.withValueInclusion(JsonInclude.Include.NON_NULL); case NON_DEFAULT: return value.withValueInclusion(JsonInclude.Include.NON_DEFAULT); case NON_EMPTY: return value.withValueInclusion(JsonInclude.Include.NON_EMPTY); case DEFAULT_INCLUSION: default: } } return value; }
@Override public JsonInclude.Include findSerializationInclusion(Annotated a, JsonInclude.Include defValue) { JsonInclude inc = a.getAnnotation(JsonInclude.class); if (inc != null) { return inc.value(); } JsonSerialize ann = a.getAnnotation(JsonSerialize.class); if (ann != null) { @SuppressWarnings("deprecation") JsonSerialize.Inclusion i2 = ann.include(); switch (i2) { case ALWAYS: return JsonInclude.Include.ALWAYS; case NON_NULL: return JsonInclude.Include.NON_NULL; case NON_DEFAULT: return JsonInclude.Include.NON_DEFAULT; case NON_EMPTY: return JsonInclude.Include.NON_EMPTY; } } return defValue; }
@Override public JsonInclude.Include findSerializationInclusion(Annotated a, JsonInclude.Include defValue) { JsonInclude inc = a.getAnnotation(JsonInclude.class); if (inc != null) { return inc.value(); } JsonSerialize ann = a.getAnnotation(JsonSerialize.class); if (ann != null) { @SuppressWarnings("deprecation") JsonSerialize.Inclusion i2 = ann.include(); switch (i2) { case ALWAYS: return JsonInclude.Include.ALWAYS; case NON_NULL: return JsonInclude.Include.NON_NULL; case NON_DEFAULT: return JsonInclude.Include.NON_DEFAULT; case NON_EMPTY: return JsonInclude.Include.NON_EMPTY; } } return defValue; }
@Override public JsonInclude.Include findSerializationInclusion(Annotated a, JsonInclude.Include defValue) { JsonInclude inc = _findAnnotation(a, JsonInclude.class); if (inc != null) { return inc.value(); } JsonSerialize ann = _findAnnotation(a, JsonSerialize.class); if (ann != null) { @SuppressWarnings("deprecation") JsonSerialize.Inclusion i2 = ann.include(); switch (i2) { case ALWAYS: return JsonInclude.Include.ALWAYS; case NON_NULL: return JsonInclude.Include.NON_NULL; case NON_DEFAULT: return JsonInclude.Include.NON_DEFAULT; case NON_EMPTY: return JsonInclude.Include.NON_EMPTY; case DEFAULT_INCLUSION: // since 2.3 -- fall through, use default break; } } return defValue; }
@Override public JsonInclude.Include findSerializationInclusion(Annotated a, JsonInclude.Include defValue) { JsonInclude inc = _findAnnotation(a, JsonInclude.class); if (inc != null) { return inc.value(); } JsonSerialize ann = _findAnnotation(a, JsonSerialize.class); if (ann != null) { @SuppressWarnings("deprecation") JsonSerialize.Inclusion i2 = ann.include(); switch (i2) { case ALWAYS: return JsonInclude.Include.ALWAYS; case NON_NULL: return JsonInclude.Include.NON_NULL; case NON_DEFAULT: return JsonInclude.Include.NON_DEFAULT; case NON_EMPTY: return JsonInclude.Include.NON_EMPTY; case DEFAULT_INCLUSION: // since 2.3 -- fall through, use default break; } } return defValue; }
@Override @SuppressWarnings("deprecation") public JsonInclude.Include findSerializationInclusion(Annotated a, JsonInclude.Include defValue) { JsonInclude inc = _findAnnotation(a, JsonInclude.class); if (inc != null) { JsonInclude.Include v = inc.value(); if (v != JsonInclude.Include.USE_DEFAULTS) { return v; } } JsonSerialize ann = _findAnnotation(a, JsonSerialize.class); if (ann != null) { JsonSerialize.Inclusion i2 = ann.include(); switch (i2) { case ALWAYS: return JsonInclude.Include.ALWAYS; case NON_NULL: return JsonInclude.Include.NON_NULL; case NON_DEFAULT: return JsonInclude.Include.NON_DEFAULT; case NON_EMPTY: return JsonInclude.Include.NON_EMPTY; case DEFAULT_INCLUSION: // since 2.3 -- fall through, use default break; } } return defValue; }
boolean valueAllowed(AccessibleProperty property, Object value, Class cls) { Include defaultInclude = serializerProvider.getConfig() == null ? Include.ALWAYS : serializerProvider.getConfig().getSerializationInclusion(); JsonInclude jsonInclude = getAnnotation(property, JsonInclude.class); JsonSerialize jsonSerialize = getAnnotation(cls, JsonSerialize.class); // Make sure local annotations win over global ones if(jsonInclude != null && jsonInclude.value() == Include.NON_NULL && value == null) { return false; } return value != null || (defaultInclude == Include.ALWAYS && jsonSerialize == null) || (jsonSerialize != null && jsonSerialize.include() == Inclusion.ALWAYS); }
@SuppressWarnings("deprecation") private JsonInclude.Value _refinePropertyInclusion(Annotated a, JsonInclude.Value value) { JsonSerialize ann = _findAnnotation(a, JsonSerialize.class); if (ann != null) { switch (ann.include()) { case ALWAYS: return value.withValueInclusion(JsonInclude.Include.ALWAYS); case NON_NULL: return value.withValueInclusion(JsonInclude.Include.NON_NULL); case NON_DEFAULT: return value.withValueInclusion(JsonInclude.Include.NON_DEFAULT); case NON_EMPTY: return value.withValueInclusion(JsonInclude.Include.NON_EMPTY); case DEFAULT_INCLUSION: default: } } return value; }
JsonSerialize ann = _findAnnotation(a, JsonSerialize.class); if (ann != null) { JsonSerialize.Inclusion i2 = ann.include(); switch (i2) { case ALWAYS: