com.fasterxml.jackson.annotation
Enum JsonInclude.Include

java.lang.Object
  extended by java.lang.Enum<JsonInclude.Include>
      extended by com.fasterxml.jackson.annotation.JsonInclude.Include
All Implemented Interfaces:
Serializable, Comparable<JsonInclude.Include>
Enclosing class:
JsonInclude

public static enum JsonInclude.Include
extends Enum<JsonInclude.Include>

Enumeration used with JsonInclude to define which properties of Java Beans are to be included in serialization.


Enum Constant Summary
ALWAYS
          Value that indicates that property is to be always included, independent of value of the property.
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.utl.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.
 
Method Summary
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.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

ALWAYS

public static final JsonInclude.Include ALWAYS
Value that indicates that property is to be always included, independent of value of the property.


NON_NULL

public static final JsonInclude.Include NON_NULL
Value that indicates that only properties with non-null values are to be included.


NON_ABSENT

public static final JsonInclude.Include NON_ABSENT
Value that indicates that properties are included unless their value is: This option is mostly used to work with "Optional"s (Java 8, Guava).

Since:
2.6

NON_EMPTY

public static final JsonInclude.Include 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:

so that as baseline, "empty" set includes values that would be excluded by both NON_NULL and NON_ABSENT.
Additionally following types have additional empty values: and for other types, null values are excluded but other exclusions (if any).

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:

With 2.7, definition has been tightened back to only containing types explained above (null, absent, empty String, empty containers), and now extended definition may be specified using NON_DEFAULT.


NON_DEFAULT

public static final JsonInclude.Include 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 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:


USE_DEFAULTS

public static final JsonInclude.Include 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 Detail

values

public static JsonInclude.Include[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (JsonInclude.Include c : JsonInclude.Include.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static JsonInclude.Include valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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 type has no constant with the specified name
NullPointerException - if the argument is null


Copyright © 2008–2016 FasterXML. All rights reserved.