java.lang.Object
tools.jackson.databind.cfg.ConstructorDetector
- All Implemented Interfaces:
Serializable
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
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumDefinition of alternate handling modes of single-argument constructors that are annotated withJsonCreatorbut 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
FieldsModifier and TypeFieldDescriptionprotected final booleanWhether implicit detection of Properties-based Constructors is allowed when there is the default (no-parameter) constructor available.protected final booleanWhether auto-detection of constructors of "JDK types" (those in packagesjava.andjavax.) is allowed or notprotected final booleanWhether explicitJsonCreatoris always required for detecting constructors (even if visible) other than the default (no argument) constructor.protected final ConstructorDetector.SingleArgConstructorstatic final ConstructorDetectorInstance used by default, which: UsesConstructorDetector.SingleArgConstructor.HEURISTICfor single-argument constructor case Does not require explicit@JsonCreatorannotations (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 packagesjava.*andjavax.*static final booleanSeeallowImplicitWithDefaultConstructor()for details.static final ConstructorDetectorInstance similar toDEFAULTexcept that for single-argument case uses setting ofConstructorDetector.SingleArgConstructor.REQUIRE_MODE.static final ConstructorDetectorInstance similar toDEFAULTexcept that for single-argument case uses setting ofConstructorDetector.SingleArgConstructor.DELEGATING.static final ConstructorDetectorInstance similar toDEFAULTexcept that for single-argument case uses setting ofConstructorDetector.SingleArgConstructor.PROPERTIES. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructorDetector(ConstructorDetector.SingleArgConstructor singleArgMode) Constructors used for default configurations which only varies by_singleArgModeprotectedConstructorDetector(ConstructorDetector.SingleArgConstructor singleArgMode, boolean requireCtorAnnotation, boolean allowJDKTypeCtors, boolean allowImplicitWithDefaultConstructor) -
Method Summary
Modifier and TypeMethodDescriptionbooleanMethod that can be used to determine whether implicit detection of Properties-based Constructors is allowed when there is a default (no-parameter) constructor available.booleanbooleanbooleanshouldIntrospectImplicitConstructors(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.booleanbooleanwithAllowImplicitWithDefaultConstructor(boolean state) Mutant factory method that can be used to change setting thatallowImplicitWithDefaultConstructor()returns.withAllowJDKTypeConstructors(boolean state) withRequireAnnotation(boolean state) withSingleArgMode(ConstructorDetector.SingleArgConstructor singleArgMode)
-
Field Details
-
DEFAULT_ALLOW_IMPLICIT_WITH_DEFAULT_CONSTRUCTOR
public static final boolean DEFAULT_ALLOW_IMPLICIT_WITH_DEFAULT_CONSTRUCTORSeeallowImplicitWithDefaultConstructor()for details.- Since:
- 3.0
- See Also:
-
DEFAULT
Instance used by default, which:- Uses
ConstructorDetector.SingleArgConstructor.HEURISTICfor single-argument constructor case - Does not require explicit
@JsonCreatorannotations (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.*andjavax.*
- Uses
-
USE_PROPERTIES_BASED
Instance similar toDEFAULTexcept that for single-argument case uses setting ofConstructorDetector.SingleArgConstructor.PROPERTIES. -
USE_DELEGATING
Instance similar toDEFAULTexcept that for single-argument case uses setting ofConstructorDetector.SingleArgConstructor.DELEGATING. -
EXPLICIT_ONLY
Instance similar toDEFAULTexcept that for single-argument case uses setting ofConstructorDetector.SingleArgConstructor.REQUIRE_MODE. -
_singleArgMode
-
_requireCtorAnnotation
protected final boolean _requireCtorAnnotationWhether explicitJsonCreatoris always required for detecting constructors (even if visible) other than the default (no argument) constructor. -
_allowJDKTypeCtors
protected final boolean _allowJDKTypeCtorsWhether auto-detection of constructors of "JDK types" (those in packagesjava.andjavax.) is allowed or not -
_allowImplicitWithDefaultConstructor
protected final boolean _allowImplicitWithDefaultConstructorWhether implicit detection of Properties-based Constructors is allowed when there is the default (no-parameter) constructor available.- Since:
- 3.0
-
-
Constructor Details
-
ConstructorDetector
protected ConstructorDetector(ConstructorDetector.SingleArgConstructor singleArgMode, boolean requireCtorAnnotation, boolean allowJDKTypeCtors, boolean allowImplicitWithDefaultConstructor) -
ConstructorDetector
Constructors used for default configurations which only varies by_singleArgMode
-
-
Method Details
-
withSingleArgMode
public ConstructorDetector withSingleArgMode(ConstructorDetector.SingleArgConstructor singleArgMode) -
withRequireAnnotation
-
withAllowJDKTypeConstructors
-
withAllowImplicitWithDefaultConstructor
Mutant factory method that can be used to change setting thatallowImplicitWithDefaultConstructor()returns.- Since:
- 3.0
-
singleArgMode
-
requireCtorAnnotation
public boolean requireCtorAnnotation() -
allowJDKTypeConstructors
public boolean allowJDKTypeConstructors() -
allowImplicitWithDefaultConstructor
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 ifshouldIntrospectImplicitConstructors(java.lang.Class<?>)returnstrue.- Since:
- 3.0
-
singleArgCreatorDefaultsToDelegating
public boolean singleArgCreatorDefaultsToDelegating() -
singleArgCreatorDefaultsToProperties
public boolean singleArgCreatorDefaultsToProperties() -
shouldIntrospectImplicitConstructors
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- Value type to consider- Returns:
- True if implicit constructor detection should be enabled; false if not
-