Module tools.jackson.databind
Class DefaultAccessorNamingStrategy.Provider
java.lang.Object
tools.jackson.databind.introspect.AccessorNamingStrategy.Provider
tools.jackson.databind.introspect.DefaultAccessorNamingStrategy.Provider
- All Implemented Interfaces:
Serializable
- Enclosing class:
- DefaultAccessorNamingStrategy
public static class DefaultAccessorNamingStrategy.Provider
extends AccessorNamingStrategy.Provider
implements Serializable
Provider for
DefaultAccessorNamingStrategy.
Default instance will use following default prefixes:
- Setter for regular POJOs: "set"
- Builder-mutator: "with"
- Regular getter: "get"
- Is-getter (for Boolean values): "is"
DefaultAccessorNamingStrategy.BaseNameValidator), preventing names like
"get_value()" and "getvalue()" (unlike Jackson 2.x that allowed these).- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final DefaultAccessorNamingStrategy.BaseNameValidatorprotected final Stringprotected final Stringprotected final Stringprotected final String -
Constructor Summary
ConstructorsModifierConstructorDescriptionProvider()protectedProvider(String setterPrefix, String withPrefix, String getterPrefix, String isGetterPrefix, DefaultAccessorNamingStrategy.BaseNameValidator vld) protectedProvider(DefaultAccessorNamingStrategy.Provider p, String setterPrefix, String withPrefix, String getterPrefix, String isGetterPrefix) protectedProvider(DefaultAccessorNamingStrategy.Provider p, DefaultAccessorNamingStrategy.BaseNameValidator vld) -
Method Summary
Modifier and TypeMethodDescriptionforBuilder(MapperConfig<?> config, AnnotatedClass builderClass, BeanDescription valueTypeDesc) Factory method for creating strategy instance for POJOs that are deserialized using Builder type: in this case eventual target (value) type is different from type of "builder" object that is used by databinding to accumulate state.forPOJO(MapperConfig<?> config, AnnotatedClass targetClass) Factory method for creating strategy instance for a "regular" POJO, called if none of the other factory methods is applicable.forRecord(MapperConfig<?> config, AnnotatedClass recordClass) Factory method for creating strategy instance for specialjava.lang.Recordtype (new in JDK 14).Mutant factory for specifying validator that is used to further verify that base name derived from accessor name is acceptable: this can be used to add further restrictions such as limit that the first character of the base name is an upper-case letter.withBuilderPrefix(String prefix) Mutant factory for changing the prefix used for Builders (from defaultJsonPOJOBuilder.DEFAULT_WITH_PREFIX)withFirstCharAcceptance(boolean allowLowerCaseFirstChar, boolean allowNonLetterFirstChar) Mutant factory for changing the rules regarding which characters are allowed as the first character of property base name, after checking and removing prefix.withGetterPrefix(String prefix) Mutant factory for changing the prefix used for "getter" methodswithIsGetterPrefix(String prefix) Mutant factory for changing the prefix used for "is-getter" methods (getters that return boolean/Boolean value).withSetterPrefix(String prefix) Mutant factory for changing the prefix used for "setter" methods
-
Field Details
-
_setterPrefix
-
_withPrefix
-
_getterPrefix
-
_isGetterPrefix
-
_baseNameValidator
-
-
Constructor Details
-
Provider
public Provider() -
Provider
protected Provider(DefaultAccessorNamingStrategy.Provider p, String setterPrefix, String withPrefix, String getterPrefix, String isGetterPrefix) -
Provider
protected Provider(DefaultAccessorNamingStrategy.Provider p, DefaultAccessorNamingStrategy.BaseNameValidator vld) -
Provider
protected Provider(String setterPrefix, String withPrefix, String getterPrefix, String isGetterPrefix, DefaultAccessorNamingStrategy.BaseNameValidator vld)
-
-
Method Details
-
withSetterPrefix
Mutant factory for changing the prefix used for "setter" methods- Parameters:
prefix- Prefix to use; or empty String""to not use any prefix (meaning signature-compatible method name is used as the property basename (and subject to name mangling)), ornullto prevent name-based detection.- Returns:
- Provider instance with specified setter-prefix
-
withBuilderPrefix
Mutant factory for changing the prefix used for Builders (from defaultJsonPOJOBuilder.DEFAULT_WITH_PREFIX)- Parameters:
prefix- Prefix to use; or empty String""to not use any prefix (meaning signature-compatible method name is used as the property basename (and subject to name mangling)), ornullto prevent name-based detection.- Returns:
- Provider instance with specified with-prefix
-
withGetterPrefix
Mutant factory for changing the prefix used for "getter" methods- Parameters:
prefix- Prefix to use; or empty String""to not use any prefix (meaning signature-compatible method name is used as the property basename (and subject to name mangling)), ornullto prevent name-based detection.- Returns:
- Provider instance with specified getter-prefix
-
withIsGetterPrefix
Mutant factory for changing the prefix used for "is-getter" methods (getters that return boolean/Boolean value).- Parameters:
prefix- Prefix to use; or empty String""to not use any prefix (meaning signature-compatible method name is used as the property basename (and subject to name mangling)). ornullto prevent name-based detection.- Returns:
- Provider instance with specified is-getter-prefix
-
withFirstCharAcceptance
public DefaultAccessorNamingStrategy.Provider withFirstCharAcceptance(boolean allowLowerCaseFirstChar, boolean allowNonLetterFirstChar) Mutant factory for changing the rules regarding which characters are allowed as the first character of property base name, after checking and removing prefix.For example, consider "getter" method candidate (no arguments, has return type) named
getValue()is considered, with "getter-prefix" defined asget, then base name isValueand the first character to consider isV. Upper-case letters are always accepted so this is fine. But with similar settings, methodget_value()would only be recognized as getter ifallowNonLetterFirstCharis set totrue: otherwise it will not be considered a getter-method. Similarly "is-getter" candidate method with nameisland()would only be considered ifallowLowerCaseFirstCharis set totrue.- Parameters:
allowLowerCaseFirstChar- Whether base names that start with lower-case letter (like"a"or"b") are accepted as valid or not: consider difference between "setter-methods"setValue()andsetvalue().allowNonLetterFirstChar- Whether base names that start with non-letter character (like"_"or number1) are accepted as valid or not: consider difference between "setter-methods"setValue()andset_value().- Returns:
- Provider instance with specified validity rules
-
withBaseNameValidator
public DefaultAccessorNamingStrategy.Provider withBaseNameValidator(DefaultAccessorNamingStrategy.BaseNameValidator vld) Mutant factory for specifying validator that is used to further verify that base name derived from accessor name is acceptable: this can be used to add further restrictions such as limit that the first character of the base name is an upper-case letter.- Parameters:
vld- Validator to use, if any;nullto indicate no additional rules- Returns:
- Provider instance with specified base name validator to use, if any
-
forPOJO
Description copied from class:AccessorNamingStrategy.ProviderFactory method for creating strategy instance for a "regular" POJO, called if none of the other factory methods is applicable.- Specified by:
forPOJOin classAccessorNamingStrategy.Provider- Parameters:
config- Current mapper configurationtargetClass- Information about value type- Returns:
- Naming strategy instance to use
-
forBuilder
public AccessorNamingStrategy forBuilder(MapperConfig<?> config, AnnotatedClass builderClass, BeanDescription valueTypeDesc) Description copied from class:AccessorNamingStrategy.ProviderFactory method for creating strategy instance for POJOs that are deserialized using Builder type: in this case eventual target (value) type is different from type of "builder" object that is used by databinding to accumulate state.- Specified by:
forBuilderin classAccessorNamingStrategy.Provider- Parameters:
config- Current mapper configurationbuilderClass- Information about builder typevalueTypeDesc- Information about the eventual target (value) type- Returns:
- Naming strategy instance to use
-
forRecord
Description copied from class:AccessorNamingStrategy.ProviderFactory method for creating strategy instance for specialjava.lang.Recordtype (new in JDK 14).- Specified by:
forRecordin classAccessorNamingStrategy.Provider- Parameters:
config- Current mapper configurationrecordClass- Information about value type (of typejava.lang.Record)- Returns:
- Naming strategy instance to use
-