Enum ObjectMapper.DefaultTyping
- All Implemented Interfaces:
Serializable
,Comparable<ObjectMapper.DefaultTyping>
,java.lang.constant.Constable
- Enclosing class:
ObjectMapper
ObjectMapper.activateDefaultTyping(PolymorphicTypeValidator)
to specify what kind of types (classes) default typing should
be used for. It will only be used if no explicit type information
is found, but this enumeration further limits subset of those types.
Since 2.4 there are special exceptions for JSON Tree model
types (sub-types of TreeNode
: default typing is never
applied to them.
Since 2.8(.4) additional checks are made to avoid attempts at default
typing primitive-valued properties.
NOTE: use of Default Typing can be a potential security risk if incoming
content comes from untrusted sources, and it is recommended that this
is either not done, or, if enabled, make sure to activateDefaultTyping(...)
methods that take PolymorphicTypeValidator
that limits applicability
to known trusted types.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionDeprecated.This value means that only properties that haveObject
as declared type (including generic types without explicit type) will use default typing.Value that means that default typing will be used for all types covered byOBJECT_AND_NON_CONCRETE
plus all array types for them.Value that means that default typing will be used for all non-final types, with exception of small number of "natural" types (String, Boolean, Integer, Double), which can be correctly inferred from JSON; as well as for all arrays of non-final types.Enables default typing for non-final types asNON_FINAL
, but also includes Enums.Value that means that default typing will be used for properties with declared type ofObject
or an abstract type (abstract class or interface). -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectMapper.DefaultTyping
Returns the enum constant of this type with the specified name.static ObjectMapper.DefaultTyping[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.Methods inherited from class java.lang.Enum
compareTo, describeConstable, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
-
Enum Constant Details
-
JAVA_LANG_OBJECT
This value means that only properties that haveObject
as declared type (including generic types without explicit type) will use default typing. -
OBJECT_AND_NON_CONCRETE
-
NON_CONCRETE_AND_ARRAYS
Value that means that default typing will be used for all types covered byOBJECT_AND_NON_CONCRETE
plus all array types for them.Since 2.4, this does NOT apply to
TreeNode
and its subtypes. -
NON_FINAL
Value that means that default typing will be used for all non-final types, with exception of small number of "natural" types (String, Boolean, Integer, Double), which can be correctly inferred from JSON; as well as for all arrays of non-final types.Since 2.4, this does NOT apply to
TreeNode
and its subtypes. -
NON_FINAL_AND_ENUMS
Enables default typing for non-final types asNON_FINAL
, but also includes Enums. Designed to allow default typing of Enums without resorting toEVERYTHING
, which has security implications.- Since:
- 2.16
-
EVERYTHING
Deprecated.Since 2.17 and removed from 3.0 --seeNON_FINAL_AND_ENUMS
for Enum-related usage.Value that means that default typing will be used for all types, with exception of small number of "natural" types (String, Boolean, Integer, Double) that can be correctly inferred from JSON, and primitives (which can not be polymorphic either). Typing is also enabled for all array types.WARNING: most of the time this is NOT the setting you want as it tends to add Type Ids everywhere, even in cases where type can not be anything other than declared (for example if declared value type of a property is
final
-- for example, properties of typelong
(or wrapperLong
).Note that this is rarely the option you should use as it results in adding type information in many places where it should not be needed: make sure you understand its behavior. The only known use case for this setting is for serialization when passing instances of final class, and base type is not separately specified.
- Since:
- 2.10
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
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 nameNullPointerException
- if the argument is null
-
NON_FINAL_AND_ENUMS
for Enum-related usage.