Enum Class JsonInclude.Include
- All Implemented Interfaces:
Serializable
,Comparable<JsonInclude.Include>
,java.lang.constant.Constable
- Enclosing class:
- JsonInclude
JsonInclude
to define which properties
of Java Beans are to be included in serialization.-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantDescriptionValue that indicates that property is to be always included, independent of value of the property.Value that indicates that separatefilter
Object (specified byJsonInclude.valueFilter()
for value itself, and/orJsonInclude.contentFilter()
for contents of structured types) is to be used for determining inclusion criteria.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.Meaning of this setting depends on context: whether annotation is specified for POJO type (class), or not.Value that indicates that only properties with null value, or what is considered empty, are not to be included.Value that indicates that only properties with non-null values are to be included.Pseudo-value used to indicate that the higher-level defaults make sense, to avoid overriding inclusion value. -
Method Summary
Modifier and TypeMethodDescriptionstatic JsonInclude.Include
Returns the enum constant of this class with the specified name.static JsonInclude.Include[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
ALWAYS
Value that indicates that property is to be always included, independent of value of the property. -
NON_NULL
Value that indicates that only properties with non-null values are to be included. -
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.
- Since:
- 2.6
-
NON_EMPTY
Value that indicates that only properties with null value, or what is considered empty, are not to be included. Definition of emptiness is data type specific; see below for details on actual handling.Default emptiness for all types includes:
Null
values.- "Absent" values (see
NON_ABSENT
)
NON_NULL
andNON_ABSENT
.
Beyond this base, following types have additional empty values:- For
Collection
s andMap
s, methodisEmpty()
is called; - For Java arrays, empty arrays are ones with length of 0
- For Java
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 methodisEmpty()
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:
- Default values of primitive types (like
0
for `int`/`java.lang.Integer` and `false` for `bool`/`Boolean`) - Timestamp 0 for date/time types
NON_DEFAULT
. -
NON_DEFAULT
Meaning of this setting depends on context: whether annotation is specified for POJO type (class), or not. In latter case annotation is either used as the global default, or as property override.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:
-
CUSTOM
Value that indicates that separatefilter
Object (specified byJsonInclude.valueFilter()
for value itself, and/orJsonInclude.contentFilter()
for contents of structured types) is to be used for determining inclusion criteria. Filter object'sequals(value)
method is called with value to serialize; if it returnstrue
value is excluded (that is, filtered out); iffalse
value is included.NOTE: the filter will be called for each non-
null
value, but handling ofnull
value differs: up to Jackson 2.13, call was only made once, but with 2.14 and later filter will be called once for eachnull
value too.- Since:
- 2.9
-
USE_DEFAULTS
Pseudo-value used to indicate that the higher-level defaults make sense, to avoid overriding inclusion value. For example, if returned for a property this would use defaults for the class that contains property, if any defined; and if none defined for that, then global serialization inclusion details.- Since:
- 2.6
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-