Top Description Inners Fields Constructors Methods
tools.jackson.databind.cfg

public final Class ConstructorDetector

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

Configurable handler used to select aspects of selecting constructor(s) to use as "Creators" 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
_allowImplicitWithDefaultConstructor

Whether implicit detection of Properties-based Constructors is allowed when there is the default (no-parameter) constructor available.

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 boolean
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, boolean allowImplicitWithDefaultConstructor)

protected
ConstructorDetector(ConstructorDetector.SingleArgConstructor singleArgMode)

Constructors used for default configurations which only varies by _singleArgMode

Method Summary

Modifier and TypeMethod and Description
public boolean
allowImplicitWithDefaultConstructor()

Method that can be used to determine whether implicit detection of Properties-based Constructors is allowed when there is a default (no-parameter) constructor available.

public boolean
public boolean
public boolean

Returns:

True if implicit constructor detection should be enabled; false if not
shouldIntrospectImplicitConstructors
(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
withAllowImplicitWithDefaultConstructor(boolean state)

Mutant factory method that can be used to change setting that allowImplicitWithDefaultConstructor returns.

public ConstructorDetector
public ConstructorDetector
withRequireAnnotation(boolean state)

public ConstructorDetector
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_allowImplicitWithDefaultConstructorback to summary
protected final boolean _allowImplicitWithDefaultConstructor

Whether implicit detection of Properties-based Constructors is allowed when there is the default (no-parameter) constructor available.

Since
3.0
_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.*
DEFAULT_ALLOW_IMPLICIT_WITH_DEFAULT_CONSTRUCTORback to summary
public static final boolean DEFAULT_ALLOW_IMPLICIT_WITH_DEFAULT_CONSTRUCTOR

See allowImplicitWithDefaultConstructor for details.

Since
3.0
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, boolean allowImplicitWithDefaultConstructor)
ConstructorDetectorback to summary
protected ConstructorDetector(ConstructorDetector.SingleArgConstructor singleArgMode)

Constructors used for default configurations which only varies by _singleArgMode

Method Detail

allowImplicitWithDefaultConstructorback to summary
public boolean allowImplicitWithDefaultConstructor()

Method that can be used to determine whether implicit detection of Properties-based Constructors is allowed when there is a default (no-parameter) constructor available. Note that this only matters if shouldIntrospectImplicitConstructors returns true.

Since
3.0
allowJDKTypeConstructorsback to summary
public boolean allowJDKTypeConstructors()
requireCtorAnnotationback to summary
public boolean requireCtorAnnotation()
shouldIntrospectImplicitConstructorsback to summary
public boolean shouldIntrospectImplicitConstructors(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()
withAllowImplicitWithDefaultConstructorback to summary
public ConstructorDetector withAllowImplicitWithDefaultConstructor(boolean state)

Mutant factory method that can be used to change setting that allowImplicitWithDefaultConstructor returns.

Since
3.0
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)
tools.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 tools.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 tools.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()