Enum WritableTypeId.Inclusion

  • All Implemented Interfaces:
    Serializable, Comparable<WritableTypeId.Inclusion>
    Enclosing class:

    public static enum WritableTypeId.Inclusion
    extends Enum<WritableTypeId.Inclusion>
    Enumeration of values that matches enum `As` from annotation `JsonTypeInfo`: separate definition to avoid dependency between streaming core and annotations packages; also allows more flexibility in case new values needed at this level of internal API.

    NOTE: in most cases this only matters with formats that do NOT have native type id capabilities, and require type id to be included within regular data (whether exposed as Java properties or not). Formats with native types usually use native type id functionality regardless, unless overridden by a feature to use "non-native" type inclusion.

    • Enum Constant Detail


        public static final WritableTypeId.Inclusion WRAPPER_ARRAY
        Inclusion as wrapper Array (1st element type id, 2nd element value).

        Corresponds to JsonTypeInfo.As.WRAPPER_ARRAY.


        public static final WritableTypeId.Inclusion WRAPPER_OBJECT
        Inclusion as wrapper Object that has one key/value pair where type id is the key for typed value.

        Corresponds to JsonTypeInfo.As.WRAPPER_OBJECT.


        public static final WritableTypeId.Inclusion METADATA_PROPERTY
        Inclusion as a property within Object to write, but logically as separate metadata that is not exposed as payload to caller: that is, does not match any of visible properties value object has.

        NOTE: if shape of typed value to write is NOT Object, will instead use WRAPPER_ARRAY inclusion.

        Corresponds to JsonTypeInfo.As.PROPERTY.


        public static final WritableTypeId.Inclusion PAYLOAD_PROPERTY
        Inclusion as a "regular" property within Object to write; this implies that its value should come from regular POJO property on serialization, and be deserialized into such property. This handling, however, is up to databinding.

        Regarding handling, type id is ONLY written as native type id; if no native type ids available, caller is assumed to handle output some other way. This is different from METADATA_PROPERTY.

        NOTE: if shape of typed value to write is NOT Object, will instead use WRAPPER_ARRAY inclusion.

        Corresponds to JsonTypeInfo.As.EXISTING_PROPERTY.


        public static final WritableTypeId.Inclusion PARENT_PROPERTY
        Inclusion as a property within "parent" Object of value Object to write. This typically requires slightly convoluted processing in which property that contains type id is actually written after typed value object itself is written.
        Note that it is illegal to call write method if the current (parent) write context is not Object: no coercion is done for other inclusion types (unlike with other xxx_PROPERTY choices. This also means that root values MAY NOT use this type id inclusion mechanism (as they have no parent context).

        Corresponds to JsonTypeInfo.As.EXTERNAL_PROPERTY.

    • Method Detail

      • values

        public static WritableTypeId.Inclusion[] 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 (WritableTypeId.Inclusion c : WritableTypeId.Inclusion.values())
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static WritableTypeId.Inclusion 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.)
        name - the name of the enum constant to be returned.
        the enum constant with the specified name
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • requiresObjectContext

        public boolean requiresObjectContext()