public static enum JsonInclude.Include extends Enum<JsonInclude.Include>
JsonInclude
to define which properties
of Java Beans are to be included in serialization.Enum Constant and Description |
---|
ALWAYS
Value that indicates that property is to be always included,
independent of value of the property.
|
CUSTOM
Value that indicates that separate `filter` Object (specified by
JsonInclude.valueFilter() for value itself, and/or
JsonInclude.contentFilter() for contents of structured types)
is to be used for determining inclusion criteria. |
NON_ABSENT
Value that indicates that properties are included unless their value
is:
null
"absent" value of a referential type (like Java 8 `Optional`, or
{link java.util.concurrent.atomic.AtomicReference}); that is, something
that would not deference to a non-null value.
|
NON_DEFAULT
Meaning of this setting depends on context: whether annotation is
specified for POJO type (class), or not.
|
NON_EMPTY
Value that indicates that only properties with null value,
or what is considered empty, are not to be included.
|
NON_NULL
Value that indicates that only properties with non-null
values are to be included.
|
USE_DEFAULTS
Pseudo-value used to indicate that the higher-level defaults make
sense, to avoid overriding inclusion value.
|
Modifier and Type | Method and Description |
---|---|
static JsonInclude.Include |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static JsonInclude.Include[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final JsonInclude.Include ALWAYS
public static final JsonInclude.Include NON_NULL
public static final JsonInclude.Include NON_ABSENT
public static final JsonInclude.Include NON_EMPTY
Default emptiness for all types includes:
Null
values.NON_ABSENT
)NON_NULL
and NON_ABSENT
.
Collection
s and Map
s,
method isEmpty()
is called;
String
s, length()
is called,
and return value of 0 indicates empty String
Note that this default handling can be overridden by custom
JsonSerializer
implementation: if method isEmpty()
is overridden, it will be called to see if non-null values are
considered empty (null is always considered empty).
Compatibility note: Jackson 2.6 included a wider range of "empty" values than either earlier (up to 2.5) or later (2.7 and beyond) types; specifically:
0
for `int`/`java.lang.Integer`
and `false` for `bool`/`Boolean`)
NON_DEFAULT
.public static final JsonInclude.Include NON_DEFAULT
When used for a POJO, definition is that only values that differ from
the default values of POJO properties are included. This is done
by creating an instance of POJO using zero-argument constructor,
and accessing property values: value is used as the default value
by using equals()
method, except for the case where property
has `null` value in which case straight null check is used.
When NOT used for a POJO (that is, as a global default, or as property override), definition is such that:
public static final JsonInclude.Include CUSTOM
JsonInclude.valueFilter()
for value itself, and/or
JsonInclude.contentFilter()
for contents of structured types)
is to be used for determining inclusion criteria.
Filter object's equals()
method is called with value
to serialize; if it returns true
value is excluded
(that is, filtered out); if false
value is included.public static final JsonInclude.Include USE_DEFAULTS
public static JsonInclude.Include[] values()
for (JsonInclude.Include c : JsonInclude.Include.values()) System.out.println(c);
public static JsonInclude.Include valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullCopyright © 2008–2021 FasterXML. All rights reserved.