Class DefaultAccessorNamingStrategy.Provider
- java.lang.Object
-
- com.fasterxml.jackson.databind.introspect.AccessorNamingStrategy.Provider
-
- com.fasterxml.jackson.databind.introspect.DefaultAccessorNamingStrategy.Provider
-
- All Implemented Interfaces:
java.io.Serializable
- Enclosing class:
- DefaultAccessorNamingStrategy
public static class DefaultAccessorNamingStrategy.Provider extends AccessorNamingStrategy.Provider implements java.io.Serializable
Provider forDefaultAccessorNamingStrategy
.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
), allowing names like "get_value()" and "getvalue()".- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Provider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AccessorNamingStrategy
forBuilder(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.AccessorNamingStrategy
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.AccessorNamingStrategy
forRecord(MapperConfig<?> config, AnnotatedClass recordClass)
Factory method for creating strategy instance for specialjava.lang.Record
type (new in JDK 14).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.DefaultAccessorNamingStrategy.Provider
withBuilderPrefix(java.lang.String prefix)
Mutant factory for changing the prefix used for Builders (from defaultJsonPOJOBuilder.DEFAULT_WITH_PREFIX
)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.DefaultAccessorNamingStrategy.Provider
withGetterPrefix(java.lang.String prefix)
Mutant factory for changing the prefix used for "getter" methodsDefaultAccessorNamingStrategy.Provider
withIsGetterPrefix(java.lang.String prefix)
Mutant factory for changing the prefix used for "is-getter" methods (getters that return boolean/Boolean value).DefaultAccessorNamingStrategy.Provider
withSetterPrefix(java.lang.String prefix)
Mutant factory for changing the prefix used for "setter" methods
-
-
-
Method Detail
-
withSetterPrefix
public DefaultAccessorNamingStrategy.Provider withSetterPrefix(java.lang.String prefix)
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)), ornull
to prevent name-based detection.- Returns:
- Provider instance with specified setter-prefix
-
withBuilderPrefix
public DefaultAccessorNamingStrategy.Provider withBuilderPrefix(java.lang.String prefix)
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)), ornull
to prevent name-based detection.- Returns:
- Provider instance with specified with-prefix
-
withGetterPrefix
public DefaultAccessorNamingStrategy.Provider withGetterPrefix(java.lang.String prefix)
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)), ornull
to prevent name-based detection.- Returns:
- Provider instance with specified getter-prefix
-
withIsGetterPrefix
public DefaultAccessorNamingStrategy.Provider withIsGetterPrefix(java.lang.String prefix)
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)). ornull
to 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 isValue
and 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 ifallowNonLetterFirstChar
is set totrue
: otherwise it will not be considered a getter-method. Similarly "is-getter" candidate method with nameisland()
would only be considered ifallowLowerCaseFirstChar
is 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;null
to indicate no additional rules- Returns:
- Provider instance with specified base name validator to use, if any
-
forPOJO
public AccessorNamingStrategy forPOJO(MapperConfig<?> config, AnnotatedClass targetClass)
Description copied from class:AccessorNamingStrategy.Provider
Factory method for creating strategy instance for a "regular" POJO, called if none of the other factory methods is applicable.- Specified by:
forPOJO
in 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.Provider
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.- Specified by:
forBuilder
in 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
public AccessorNamingStrategy forRecord(MapperConfig<?> config, AnnotatedClass recordClass)
Description copied from class:AccessorNamingStrategy.Provider
Factory method for creating strategy instance for specialjava.lang.Record
type (new in JDK 14).- Specified by:
forRecord
in classAccessorNamingStrategy.Provider
- Parameters:
config
- Current mapper configurationrecordClass
- Information about value type (of typejava.lang.Record
)- Returns:
- Naming strategy instance to use
-
-