Enum Class Nulls

java.lang.Object
java.lang.Enum<Nulls>
org.apache.juneau.marshall.Nulls
All Implemented Interfaces:
Serializable, Comparable<Nulls>, Constable

public enum Nulls extends Enum<Nulls>
Per-property null-coercion modes consulted by parsers when an explicit null (or absent Optional) is encountered on the wire.

Juneau's analog of Jackson's com.fasterxml.jackson.annotation.Nulls. The selected mode decides what the parser does at the moment of setting the bean property — it does not affect serialization.

Precedence:

  1. Per-property @MarshalledProp(nulls=…).
  2. Context-level default on Parser.Builder.nulls(Nulls).
  3. LEAVE when neither is set.
Optional contract:

For an Optional-typed property, EMPTY and DEFAULT both resolve to Optional.empty() — never a bare null inside the Optional. The same rule applies to OptionalInt, OptionalLong, and OptionalDouble.

Since:
10.0.0
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    Substitute the bean-constructed default for this property — the value the property holds on a fresh no-arg-constructed instance of the bean.
    Substitute the type's "empty" value: String → "" Collection → empty collection (preserves declared type when possible) Map → empty map Array → zero-length array of the declared element type Optional / OptionalInt / OptionalLong / OptionalDouble → the corresponding empty() sentinel Primitive — the Java primitive default (0, false, (char)0) Other reference types — falls back to LEAVE
    Pass the null value through to the setter unchanged.
    Sentinel meaning "no value configured" — falls through to the next-higher precedence level.
    Do not call the setter at all.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Nulls
    Returns the enum constant of this class with the specified name.
    static Nulls[]
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • NOT_SET

      public static final Nulls NOT_SET
      Sentinel meaning "no value configured" — falls through to the next-higher precedence level.
    • LEAVE

      public static final Nulls LEAVE
      Pass the null value through to the setter unchanged.

      For an Optional-typed property this resolves to Optional.empty() per the shared Optional contract — never a bare null inside the Optional.

      This is the default behavior when no policy is configured.

    • EMPTY

      public static final Nulls EMPTY
      Substitute the type's "empty" value:
      • String → ""
      • Collection → empty collection (preserves declared type when possible)
      • Map → empty map
      • Array → zero-length array of the declared element type
      • Optional / OptionalInt / OptionalLong / OptionalDouble → the corresponding empty() sentinel
      • Primitive — the Java primitive default (0, false, (char)0)
      • Other reference types — falls back to LEAVE
    • DEFAULT

      public static final Nulls DEFAULT
      Substitute the bean-constructed default for this property — the value the property holds on a fresh no-arg-constructed instance of the bean.

      The reference instance is built once per bean class (and cached on its ClassMeta). When no reference instance can be built (no accessible no-arg ctor / constructor throws), this mode silently falls back to LEAVE.

    • SKIP

      public static final Nulls SKIP
      Do not call the setter at all.

      Any value already present on the bean (typically the bean's own field-initializer value) is preserved. This is useful for properties whose absence on the wire should be treated as "no change" rather than "reset to null".

  • Method Details

    • values

      public static Nulls[] 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

      public static Nulls valueOf(String name)
      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 name
      NullPointerException - if the argument is null