Class ConstructorDetector
- java.lang.Object
-
- com.fasterxml.jackson.databind.cfg.ConstructorDetector
-
- All Implemented Interfaces:
java.io.Serializable
public final class ConstructorDetector extends java.lang.Object implements java.io.SerializableConfigurable 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
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classConstructorDetector.SingleArgConstructorDefinition 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
Fields Modifier and Type Field Description static ConstructorDetectorDEFAULTInstance 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 ConstructorDetectorEXPLICIT_ONLYInstance similar toDEFAULTexcept that for single-argument case uses setting ofConstructorDetector.SingleArgConstructor.REQUIRE_MODE.static ConstructorDetectorUSE_DELEGATINGInstance similar toDEFAULTexcept that for single-argument case uses setting ofConstructorDetector.SingleArgConstructor.DELEGATING.static ConstructorDetectorUSE_PROPERTIES_BASEDInstance similar toDEFAULTexcept that for single-argument case uses setting ofConstructorDetector.SingleArgConstructor.PROPERTIES.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanallowJDKTypeConstructors()booleanrequireCtorAnnotation()booleanshouldIntrospectorImplicitConstructors(java.lang.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.booleansingleArgCreatorDefaultsToDelegating()booleansingleArgCreatorDefaultsToProperties()ConstructorDetector.SingleArgConstructorsingleArgMode()ConstructorDetectorwithAllowJDKTypeConstructors(boolean state)ConstructorDetectorwithRequireAnnotation(boolean state)ConstructorDetectorwithSingleArgMode(ConstructorDetector.SingleArgConstructor singleArgMode)
-
-
-
Field Detail
-
DEFAULT
public static final ConstructorDetector 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
public static final ConstructorDetector USE_PROPERTIES_BASED
Instance similar toDEFAULTexcept that for single-argument case uses setting ofConstructorDetector.SingleArgConstructor.PROPERTIES.
-
USE_DELEGATING
public static final ConstructorDetector USE_DELEGATING
Instance similar toDEFAULTexcept that for single-argument case uses setting ofConstructorDetector.SingleArgConstructor.DELEGATING.
-
EXPLICIT_ONLY
public static final ConstructorDetector EXPLICIT_ONLY
Instance similar toDEFAULTexcept that for single-argument case uses setting ofConstructorDetector.SingleArgConstructor.REQUIRE_MODE.
-
-
Method Detail
-
withSingleArgMode
public ConstructorDetector withSingleArgMode(ConstructorDetector.SingleArgConstructor singleArgMode)
-
withRequireAnnotation
public ConstructorDetector withRequireAnnotation(boolean state)
-
withAllowJDKTypeConstructors
public ConstructorDetector withAllowJDKTypeConstructors(boolean state)
-
singleArgMode
public ConstructorDetector.SingleArgConstructor singleArgMode()
-
requireCtorAnnotation
public boolean requireCtorAnnotation()
-
allowJDKTypeConstructors
public boolean allowJDKTypeConstructors()
-
singleArgCreatorDefaultsToDelegating
public boolean singleArgCreatorDefaultsToDelegating()
-
singleArgCreatorDefaultsToProperties
public boolean singleArgCreatorDefaultsToProperties()
-
shouldIntrospectorImplicitConstructors
public boolean shouldIntrospectorImplicitConstructors(java.lang.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- Value type to consider- Returns:
- True if implicit constructor detection should be enabled; false if not
-
-