AccessorNamingStrategy used by Jackson: to be used either as-is,
or as base-class with overrides.
| Modifier and Type | Class and Description |
|---|---|
| public static interface | DefaultAccessorNamingStrategy.BaseNameValidator
Definition of a handler API to use for checking whether given base name (remainder of accessor method name after removing prefix) is acceptable based on various rules. |
| public static class | DefaultAccessorNamingStrategy.FirstCharBasedValidator
Simple implementation of |
| public static class | |
| public static class | DefaultAccessorNamingStrategy.RecordNaming
Implementation used for supporting "non-prefix" naming convention of
Java 14 |
| Modifier and Type | Field and Description |
|---|---|
| protected final DefaultAccessorNamingStrategy. | _baseNameValidator
Optional validator for checking that base name |
| protected final MapperConfig | |
| protected final AnnotatedClass | |
| protected final String | |
| protected final String | |
| protected final boolean | |
| protected final String | _mutatorPrefix
Prefix used by auto-detected mutators ("setters"): usually "set", but differs for builder objects ("with" by default). |
| protected final boolean |
| Access | Constructor and Description |
|---|---|
| protected | DefaultAccessorNamingStrategy(MapperConfig<?> config, AnnotatedClass forClass, String mutatorPrefix, String getterPrefix, String isGetterPrefix, DefaultAccessorNamingStrategy.
|
| Modifier and Type | Method and Description |
|---|---|
| private boolean | |
| protected boolean | |
| protected boolean | |
| public String | findNameForIsGetter(AnnotatedMethod
Method to check am, String Name to check (usually same as name)AnnotatedMethod#getName()Implements abstract com. Note that signature acceptability has already been checked (no arguments, has return value) but NOT the specific limitation that return type should be of boolean type -- implementation should apply latter check, if so desired (some languages may use different criteria). |
| public String | findNameForMutator(AnnotatedMethod
Method to check am, String Name to check (usually same as name)AnnotatedMethod#getName()Implements abstract com. Note that signature acceptability has already been checked (exactly one parameter) by caller. |
| public String | findNameForRegularGetter(AnnotatedMethod
Method to check am, String Name to check (usually same as name)AnnotatedMethod#getName()Implements abstract com. Note that signature acceptability has already been checked (no arguments, does have a return value) by caller. |
| protected String | legacyManglePropertyName(final String
Name of accessor/mutator method, not including prefix
("get"/"is"/"set") basename, final int offset)Method called to figure out name of the property, given corresponding suggested name based on a method or field name. |
| public String | modifyFieldName(AnnotatedField
Field to check field, String Name to check (usually same as name)AnnotatedField#getName()Implements abstract com. |
| protected String |
| _baseNameValidator | back to summary |
|---|---|
| protected final DefaultAccessorNamingStrategy. Optional validator for checking that base name | |
| _config | back to summary |
|---|---|
| protected final MapperConfig<?> _config | |
| _forClass | back to summary |
|---|---|
| protected final AnnotatedClass _forClass | |
| _getterPrefix | back to summary |
|---|---|
| protected final String _getterPrefix | |
| _isGetterPrefix | back to summary |
|---|---|
protected final String _isGetterPrefix
| |
| _isGettersNonBoolean | back to summary |
|---|---|
| protected final boolean _isGettersNonBoolean | |
| _mutatorPrefix | back to summary |
|---|---|
| protected final String _mutatorPrefix Prefix used by auto-detected mutators ("setters"): usually "set", but differs for builder objects ("with" by default). | |
| _stdBeanNaming | back to summary |
|---|---|
| protected final boolean _stdBeanNaming | |
| DefaultAccessorNamingStrategy | back to summary |
|---|---|
| protected DefaultAccessorNamingStrategy(MapperConfig<?> config, AnnotatedClass forClass, String mutatorPrefix, String getterPrefix, String isGetterPrefix, DefaultAccessorNamingStrategy. | |
| _booleanType | back to summary |
|---|---|
| private boolean _booleanType(JavaType type) | |
| _isCglibGetCallbacks | back to summary |
|---|---|
| protected boolean _isCglibGetCallbacks(AnnotatedMethod am) | |
| _isGroovyMetaClassGetter | back to summary |
|---|---|
| protected boolean _isGroovyMetaClassGetter(AnnotatedMethod am) | |
| findNameForIsGetter | back to summary |
|---|---|
| public String findNameForIsGetter(AnnotatedMethod am, String name) Implements abstract com. Doc from com. Method called to find whether given method would be considered an "is-getter" getter method in context of type introspected, and if so, what is the logical property it is associated with (which in turn suggest external name for property) Note that signature acceptability has already been checked (no arguments, has return value) but NOT the specific limitation that return type should be of boolean type -- implementation should apply latter check, if so desired (some languages may use different criteria). It is also possible that some implementations allow different return types than boolean types. Note that visibility checks are applied separately; strategy does not need to be concerned with that aspect.
| |
| findNameForMutator | back to summary |
|---|---|
| public String findNameForMutator(AnnotatedMethod am, String name) Implements abstract com. Doc from com. Method called to find whether given method would be considered a "mutator" (usually setter, but for builders "with-method" or similar) in context of type introspected, and if so, what is the logical property it is associated with (which in turn suggest external name for property) Note that signature acceptability has already been checked (exactly one parameter) by caller. Note that visibility checks are applied separately; strategy does not need to be concerned with that aspect.
| |
| findNameForRegularGetter | back to summary |
|---|---|
| public String findNameForRegularGetter(AnnotatedMethod am, String name) Implements abstract com. Doc from com. Method called to find whether given method would be considered a "regular" getter method in context of type introspected, and if so, what is the logical property it is associated with (which in turn suggest external name for property) Note that signature acceptability has already been checked (no arguments, does have a return value) by caller.
Note that this method MAY be called for potential "is-getter" methods too
(before Note that visibility checks are applied separately; strategy does not need to be concerned with that aspect.
| |
| legacyManglePropertyName | back to summary |
|---|---|
| protected String legacyManglePropertyName(final String basename, final int offset) Method called to figure out name of the property, given corresponding suggested name based on a method or field name.
| |
| modifyFieldName | back to summary |
|---|---|
| public String modifyFieldName(AnnotatedField field, String name) Implements abstract com. Doc from com. Method called to find the name of logical property that given field should be associated with, if any. Note that visibility checks are applied separately; strategy does not need to be concerned with that aspect.
| |
| stdManglePropertyName | back to summary |
|---|---|
| protected String stdManglePropertyName(final String basename, final int offset) | |
| Modifier and Type | Method and Description |
|---|---|
| public boolean |
| accept | back to summary |
|---|---|
| public boolean accept(char firstChar, String basename, int offset) | |
BaseNameValidator that checks the
first character and nothing else.
Instances are to be constructed using method
FirstCharBasedValidator#forFirstNameRule.
| Modifier and Type | Field and Description |
|---|---|
| private final boolean | |
| private final boolean |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | accept(char firstChar, String basename, int offset)
Implements com. |
| public static DefaultAccessorNamingStrategy. | Returns: Validator instance to use, if any;null to indicate no additional
rules applied (case when both arguments are false)Whether base names that start with lower-case
letter (like allowLowerCaseFirstChar, boolean "a" or "b") are accepted as valid or not:
consider difference between "setter-methods" setValue() and setvalue().Whether base names that start with non-letter
character (like allowNonLetterFirstChar)"_" or number 1) are accepted as valid or not:
consider difference between "setter-methods" setValue() and set_value().Factory method to use for getting an instance with specified first-character
restrictions, if any; or |
| _allowLowerCaseFirstChar | back to summary |
|---|---|
| private final boolean _allowLowerCaseFirstChar | |
| _allowNonLetterFirstChar | back to summary |
|---|---|
| private final boolean _allowNonLetterFirstChar | |
| FirstCharBasedValidator | back to summary |
|---|---|
| protected FirstCharBasedValidator(boolean allowLowerCaseFirstChar, boolean allowNonLetterFirstChar) | |
| accept | back to summary |
|---|---|
| public boolean accept(char firstChar, String basename, int offset) Implements com.
| |
| forFirstNameRule | back to summary |
|---|---|
| public static DefaultAccessorNamingStrategy. Factory method to use for getting an instance with specified first-character
restrictions, if any; or
| |
DefaultAccessorNamingStrategy.
Default instance will use following default prefixes:
BaseNameValidator), allowing names like
"get_value()" and "getvalue()".
| Modifier and Type | Field and Description |
|---|---|
| protected final DefaultAccessorNamingStrategy. | |
| protected final String | |
| protected final String | |
| protected final String | |
| protected final String | |
| private static final long |
| Access | Constructor and Description |
|---|---|
| public | |
| protected | |
| protected | |
| protected | Provider(String setterPrefix, String withPrefix, String getterPrefix, String isGetterPrefix, DefaultAccessorNamingStrategy.
|
| Modifier and Type | Method and Description |
|---|---|
| public AccessorNamingStrategy | forBuilder(MapperConfig<?>
Current mapper configuration config, AnnotatedClass Information about builder type builderClass, BeanDescription Information about the eventual target (value) type valueTypeDesc)Implements abstract com. |
| public AccessorNamingStrategy | forPOJO(MapperConfig<?>
Current mapper configuration config, AnnotatedClass Information about value type targetClass)Implements abstract com. |
| public AccessorNamingStrategy | forRecord(MapperConfig<?>
Current mapper configuration config, AnnotatedClass Information about value type (of type recordClass)java.lang.Record)Implements abstract com. java.lang.Record
type (new in JDK 14).
|
| public DefaultAccessorNamingStrategy. | Returns: Provider instance with specified base name validator to use, if anyValidator to use, if any; vldnull to indicate no additional rulesMutant 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. |
| public DefaultAccessorNamingStrategy. | Returns: Provider instance with specified with-prefixPrefix to use; or empty String prefix)"" to not use
any prefix (meaning signature-compatible method name is used as
the property basename (and subject to name mangling)),
or null to prevent name-based detection.Mutant factory for changing the prefix used for Builders
(from default |
| public DefaultAccessorNamingStrategy. | Returns: Provider instance with specified validity rulesWhether base names that start with lower-case
letter (like allowLowerCaseFirstChar, boolean "a" or "b") are accepted as valid or not:
consider difference between "setter-methods" setValue() and setvalue().Whether base names that start with non-letter
character (like allowNonLetterFirstChar)"_" or number 1) are accepted as valid or not:
consider difference between "setter-methods" setValue() and set_value().Mutant factory for changing the rules regarding which characters are allowed as the first character of property base name, after checking and removing prefix. |
| public DefaultAccessorNamingStrategy. | Returns: Provider instance with specified getter-prefixPrefix to use; or empty String prefix)"" to not use
any prefix (meaning signature-compatible method name is used as
the property basename (and subject to name mangling)),
or null to prevent name-based detection.Mutant factory for changing the prefix used for "getter" methods |
| public DefaultAccessorNamingStrategy. | Returns: Provider instance with specified is-getter-prefixPrefix to use; or empty String prefix)"" to not use
any prefix (meaning signature-compatible method name is used as
the property basename (and subject to name mangling)).
or null to prevent name-based detection.Mutant factory for changing the prefix used for "is-getter" methods (getters that return boolean/Boolean value). |
| public DefaultAccessorNamingStrategy. | Returns: Provider instance with specified setter-prefixPrefix to use; or empty String prefix)"" to not use
any prefix (meaning signature-compatible method name is used as
the property basename (and subject to name mangling)),
or null to prevent name-based detection.Mutant factory for changing the prefix used for "setter" methods |
| _baseNameValidator | back to summary |
|---|---|
| protected final DefaultAccessorNamingStrategy. | |
| _getterPrefix | back to summary |
|---|---|
| protected final String _getterPrefix | |
| _isGetterPrefix | back to summary |
|---|---|
| protected final String _isGetterPrefix | |
| _setterPrefix | back to summary |
|---|---|
| protected final String _setterPrefix | |
| _withPrefix | back to summary |
|---|---|
| protected final String _withPrefix | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides com. | |
| Provider | back to summary |
|---|---|
| public Provider() | |
| Provider | back to summary |
|---|---|
| protected Provider(DefaultAccessorNamingStrategy. | |
| Provider | back to summary |
|---|---|
| protected Provider(DefaultAccessorNamingStrategy. | |
| Provider | back to summary |
|---|---|
| protected Provider(String setterPrefix, String withPrefix, String getterPrefix, String isGetterPrefix, DefaultAccessorNamingStrategy. | |
| forBuilder | back to summary |
|---|---|
| public AccessorNamingStrategy forBuilder(MapperConfig<?> config, AnnotatedClass builderClass, BeanDescription valueTypeDesc) Implements abstract com. Doc from com. 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 | back to summary |
|---|---|
| public AccessorNamingStrategy forPOJO(MapperConfig<?> config, AnnotatedClass targetClass) Implements abstract com. Doc from com. Factory method for creating strategy instance for a "regular" POJO, called if none of the other factory methods is applicable.
| |
| forRecord | back to summary |
|---|---|
| public AccessorNamingStrategy forRecord(MapperConfig<?> config, AnnotatedClass recordClass) Implements abstract com. Doc from com. Factory method for creating strategy instance for special
| |
| withBaseNameValidator | back to summary |
|---|---|
| public DefaultAccessorNamingStrategy. 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 | back to summary |
|---|---|
| public DefaultAccessorNamingStrategy. Mutant factory for changing the prefix used for Builders
(from default
| |
| withFirstCharAcceptance | back to summary |
|---|---|
| public DefaultAccessorNamingStrategy. 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
| |
| withGetterPrefix | back to summary |
|---|---|
| public DefaultAccessorNamingStrategy. Mutant factory for changing the prefix used for "getter" methods
| |
| withIsGetterPrefix | back to summary |
|---|---|
| public DefaultAccessorNamingStrategy. Mutant factory for changing the prefix used for "is-getter" methods (getters that return boolean/Boolean value).
| |
| withSetterPrefix | back to summary |
|---|---|
| public DefaultAccessorNamingStrategy. Mutant factory for changing the prefix used for "setter" methods
| |
java.lang.Record types, and in particular find default
accessors for declared record fields.
Current / initial implementation will also recognize additional "normal" getters ("get"-prefix) and is-getters ("is"-prefix and boolean return value) by name.
| Modifier and Type | Field and Description |
|---|---|
| protected final Set | _fieldNames
Names of actual Record fields from definition; auto-detected. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public String | findNameForRegularGetter(AnnotatedMethod
Method to check am, String Name to check (usually same as name)AnnotatedMethod#getName()Overrides com. Note that signature acceptability has already been checked (no arguments, does have a return value) by caller. |
| _fieldNames | back to summary |
|---|---|
| protected final Set<String> _fieldNames Names of actual Record fields from definition; auto-detected. | |
| RecordNaming | back to summary |
|---|---|
| public RecordNaming(MapperConfig<?> config, AnnotatedClass forClass) | |
| findNameForRegularGetter | back to summary |
|---|---|
| public String findNameForRegularGetter(AnnotatedMethod am, String name) Overrides com. Doc from com. Method called to find whether given method would be considered a "regular" getter method in context of type introspected, and if so, what is the logical property it is associated with (which in turn suggest external name for property) Note that signature acceptability has already been checked (no arguments, does have a return value) by caller.
Note that this method MAY be called for potential "is-getter" methods too
(before Note that visibility checks are applied separately; strategy does not need to be concerned with that aspect.
| |