Top Description Inners Fields Constructors Methods
com.fasterxml.jackson.databind.cfg

public final Class ConstructorDetector

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Imports
com.fasterxml.jackson.databind.util.ClassUtil

Configurable handler used to select aspects of selecting constructor to use as "Creator" for POJOs. Defines the API for handlers, a pre-defined set of standard instances and methods for constructing alternative configurations.
Since
2.12

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
ConstructorDetector.SingleArgConstructor

Definition of alternate handling modes of single-argument constructors that are annotated with com.fasterxml.jackson.annotation.JsonCreator but without "mode" definition (or explicit name for the argument): this is the case where two interpretations are possible -- "properties" (in which case the argument is named parameter of a JSON Object) and "delegating (in which case the argument maps to the whole JSON value).

Field Summary

Modifier and TypeField and Description
protected final boolean
_allowJDKTypeCtors

Whether auto-detection of constructors of "JDK types" (those in packages java.

protected final boolean
_requireCtorAnnotation

Whether explicit com.fasterxml.jackson.annotation.JsonCreator is always required for detecting constructors (even if visible) other than the default (no argument) constructor.

protected final ConstructorDetector.SingleArgConstructor
public static final ConstructorDetector
DEFAULT

Instance used by default, which:

  • Uses SingleArgConstructor#HEURISTIC for single-argument constructor case
  • Does not require explicit @JsonCreator annotations (so allows auto-detection of Visible constructors} (except for JDK types)
  • Does not allow auto-detection of Visible constructors for so-called JDK types; that is, classes in packages java.* and javax.*
public static final ConstructorDetector
EXPLICIT_ONLY

Instance similar to DEFAULT except that for single-argument case uses setting of SingleArgConstructor#REQUIRE_MODE.

private static final long
public static final ConstructorDetector
USE_DELEGATING

Instance similar to DEFAULT except that for single-argument case uses setting of SingleArgConstructor#DELEGATING.

public static final ConstructorDetector
USE_PROPERTIES_BASED

Instance similar to DEFAULT except that for single-argument case uses setting of SingleArgConstructor#PROPERTIES.

Constructor Summary

AccessConstructor and Description
protected
ConstructorDetector(ConstructorDetector.SingleArgConstructor singleArgMode, boolean requireCtorAnnotation, boolean allowJDKTypeCtors)

protected
ConstructorDetector(ConstructorDetector.SingleArgConstructor singleArgMode)

Constructors used for default configurations which only varies by _singleArgMode

Method Summary

Modifier and TypeMethod and Description
public boolean
public boolean
public boolean

Returns:

True if implicit constructor detection should be enabled; false if not
shouldIntrospectorImplicitConstructors
(Class<?>
Value type to consider
rawType
)

Accessor that combines checks for whether implicit creators are allowed and, if so, whether JDK type constructors are allowed (if type is JDK type) to determine whether implicit constructor detection should be enabled for given type or not.

public boolean
public boolean
public ConstructorDetector.SingleArgConstructor
public ConstructorDetector
public ConstructorDetector
withRequireAnnotation(boolean state)

public ConstructorDetector
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_allowJDKTypeCtorsback to summary
protected final boolean _allowJDKTypeCtors

Whether auto-detection of constructors of "JDK types" (those in packages java. and javax.) is allowed or not

_requireCtorAnnotationback to summary
protected final boolean _requireCtorAnnotation

Whether explicit com.fasterxml.jackson.annotation.JsonCreator is always required for detecting constructors (even if visible) other than the default (no argument) constructor.

_singleArgModeback to summary
protected final ConstructorDetector.SingleArgConstructor _singleArgMode
DEFAULTback to summary
public static final ConstructorDetector DEFAULT

Instance used by default, which:

  • Uses SingleArgConstructor#HEURISTIC for single-argument constructor case
  • Does not require explicit @JsonCreator annotations (so allows auto-detection of Visible constructors} (except for JDK types)
  • Does not allow auto-detection of Visible constructors for so-called JDK types; that is, classes in packages java.* and javax.*
EXPLICIT_ONLYback to summary
public static final ConstructorDetector EXPLICIT_ONLY

Instance similar to DEFAULT except that for single-argument case uses setting of SingleArgConstructor#REQUIRE_MODE.

serialVersionUIDback to summary
private static final long serialVersionUID
USE_DELEGATINGback to summary
public static final ConstructorDetector USE_DELEGATING

Instance similar to DEFAULT except that for single-argument case uses setting of SingleArgConstructor#DELEGATING.

USE_PROPERTIES_BASEDback to summary
public static final ConstructorDetector USE_PROPERTIES_BASED

Instance similar to DEFAULT except that for single-argument case uses setting of SingleArgConstructor#PROPERTIES.

Constructor Detail

ConstructorDetectorback to summary
protected ConstructorDetector(ConstructorDetector.SingleArgConstructor singleArgMode, boolean requireCtorAnnotation, boolean allowJDKTypeCtors)
ConstructorDetectorback to summary
protected ConstructorDetector(ConstructorDetector.SingleArgConstructor singleArgMode)

Constructors used for default configurations which only varies by _singleArgMode

Method Detail

allowJDKTypeConstructorsback to summary
public boolean allowJDKTypeConstructors()
requireCtorAnnotationback to summary
public boolean requireCtorAnnotation()
shouldIntrospectorImplicitConstructorsback to summary
public boolean shouldIntrospectorImplicitConstructors(Class<?> rawType)

Accessor that combines checks for whether implicit creators are allowed and, if so, whether JDK type constructors are allowed (if type is JDK type) to determine whether implicit constructor detection should be enabled for given type or not.

Parameters
rawType:Class<?>

Value type to consider

Returns:boolean

True if implicit constructor detection should be enabled; false if not

singleArgCreatorDefaultsToDelegatingback to summary
public boolean singleArgCreatorDefaultsToDelegating()
singleArgCreatorDefaultsToPropertiesback to summary
public boolean singleArgCreatorDefaultsToProperties()
singleArgModeback to summary
public ConstructorDetector.SingleArgConstructor singleArgMode()
withAllowJDKTypeConstructorsback to summary
public ConstructorDetector withAllowJDKTypeConstructors(boolean state)
withRequireAnnotationback to summary
public ConstructorDetector withRequireAnnotation(boolean state)
withSingleArgModeback to summary
public ConstructorDetector withSingleArgMode(ConstructorDetector.SingleArgConstructor singleArgMode)
com.fasterxml.jackson.databind.cfg back to summary

public final Enum ConstructorDetector.SingleArgConstructor

extends Enum<ConstructorDetector.SingleArgConstructor>
Class Inheritance

Definition of alternate handling modes of single-argument constructors that are annotated with com.fasterxml.jackson.annotation.JsonCreator but without "mode" definition (or explicit name for the argument): this is the case where two interpretations are possible -- "properties" (in which case the argument is named parameter of a JSON Object) and "delegating (in which case the argument maps to the whole JSON value).

Default choice is HEURISTIC (which is Jackson pre-2.12 always uses)

Note

does NOT have any effect if explicit @JsonCreator annotation is required.

Since
2.12

Field Summary

Modifier and TypeField and Description
public static final ConstructorDetector.SingleArgConstructor
DELEGATING

Assume "delegating" mode if not explicitly annotated otherwise

public static final ConstructorDetector.SingleArgConstructor
HEURISTIC

Use heuristics to see if "properties" mode is to be used (POJO has a property with the same name as the implicit name [if available] of the constructor argument).

public static final ConstructorDetector.SingleArgConstructor
PROPERTIES

Assume "properties" mode if not explicitly annotated otherwise

public static final ConstructorDetector.SingleArgConstructor
REQUIRE_MODE

Refuse to decide implicit mode and instead throw a com.fasterxml.jackson.databind.exc.InvalidDefinitionException in ambiguous case.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static ConstructorDetector.SingleArgConstructor
public static ConstructorDetector.SingleArgConstructor[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

DELEGATINGback to summary
public static final ConstructorDetector.SingleArgConstructor DELEGATING

Assume "delegating" mode if not explicitly annotated otherwise

HEURISTICback to summary
public static final ConstructorDetector.SingleArgConstructor HEURISTIC

Use heuristics to see if "properties" mode is to be used (POJO has a property with the same name as the implicit name [if available] of the constructor argument).

Note

this is the default choice for Jackson versions before 2.12.

PROPERTIESback to summary
public static final ConstructorDetector.SingleArgConstructor PROPERTIES

Assume "properties" mode if not explicitly annotated otherwise

REQUIRE_MODEback to summary
public static final ConstructorDetector.SingleArgConstructor REQUIRE_MODE

Refuse to decide implicit mode and instead throw a com.fasterxml.jackson.databind.exc.InvalidDefinitionException in ambiguous case.

Constructor Detail

SingleArgConstructorback to summary
private SingleArgConstructor()

Method Detail

valueOfback to summary
public static ConstructorDetector.SingleArgConstructor valueOf(String name)
valuesback to summary
public static ConstructorDetector.SingleArgConstructor[] values()