Class DefaultAccessorNamingStrategy
- java.lang.Object
-
- com.fasterxml.jackson.databind.introspect.AccessorNamingStrategy
-
- com.fasterxml.jackson.databind.introspect.DefaultAccessorNamingStrategy
-
- Direct Known Subclasses:
DefaultAccessorNamingStrategy.RecordNaming
public class DefaultAccessorNamingStrategy extends AccessorNamingStrategy
DefaultAccessorNamingStrategyused by Jackson: to be used either as-is, or as base-class with overrides.- Since:
- 2.12
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceDefaultAccessorNamingStrategy.BaseNameValidatorDefinition 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.static classDefaultAccessorNamingStrategy.FirstCharBasedValidatorSimple implementation ofDefaultAccessorNamingStrategy.BaseNameValidatorthat checks the first character and nothing else.static classDefaultAccessorNamingStrategy.ProviderProvider forDefaultAccessorNamingStrategy.static classDefaultAccessorNamingStrategy.RecordNamingImplementation used for supporting "non-prefix" naming convention of Java 14java.lang.Recordtypes, and in particular find default accessors for declared record fields.-
Nested classes/interfaces inherited from class com.fasterxml.jackson.databind.introspect.AccessorNamingStrategy
AccessorNamingStrategy.Base
-
-
Field Summary
Fields Modifier and Type Field Description protected DefaultAccessorNamingStrategy.BaseNameValidator_baseNameValidatorOptional validator for checking that base nameprotected MapperConfig<?>_configprotected AnnotatedClass_forClassprotected java.lang.String_getterPrefixprotected java.lang.String_isGetterPrefixprotected boolean_isGettersNonBooleanprotected java.lang.String_mutatorPrefixPrefix used by auto-detected mutators ("setters"): usually "set", but differs for builder objects ("with" by default).protected boolean_stdBeanNaming
-
Constructor Summary
Constructors Modifier Constructor Description protectedDefaultAccessorNamingStrategy(MapperConfig<?> config, AnnotatedClass forClass, java.lang.String mutatorPrefix, java.lang.String getterPrefix, java.lang.String isGetterPrefix, DefaultAccessorNamingStrategy.BaseNameValidator baseNameValidator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean_isCglibGetCallbacks(AnnotatedMethod am)protected boolean_isGroovyMetaClassGetter(AnnotatedMethod am)java.lang.StringfindNameForIsGetter(AnnotatedMethod am, java.lang.String name)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)java.lang.StringfindNameForMutator(AnnotatedMethod am, java.lang.String name)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)java.lang.StringfindNameForRegularGetter(AnnotatedMethod am, java.lang.String name)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)protected java.lang.StringlegacyManglePropertyName(java.lang.String basename, int offset)Method called to figure out name of the property, given corresponding suggested name based on a method or field name.java.lang.StringmodifyFieldName(AnnotatedField field, java.lang.String name)Method called to find the name of logical property that given field should be associated with, if any.protected java.lang.StringstdManglePropertyName(java.lang.String basename, int offset)
-
-
-
Field Detail
-
_config
protected final MapperConfig<?> _config
-
_forClass
protected final AnnotatedClass _forClass
-
_baseNameValidator
protected final DefaultAccessorNamingStrategy.BaseNameValidator _baseNameValidator
Optional validator for checking that base name
-
_stdBeanNaming
protected final boolean _stdBeanNaming
-
_isGettersNonBoolean
protected final boolean _isGettersNonBoolean
-
_getterPrefix
protected final java.lang.String _getterPrefix
-
_isGetterPrefix
protected final java.lang.String _isGetterPrefix
- Since:
- 2.14
-
_mutatorPrefix
protected final java.lang.String _mutatorPrefix
Prefix used by auto-detected mutators ("setters"): usually "set", but differs for builder objects ("with" by default).
-
-
Constructor Detail
-
DefaultAccessorNamingStrategy
protected DefaultAccessorNamingStrategy(MapperConfig<?> config, AnnotatedClass forClass, java.lang.String mutatorPrefix, java.lang.String getterPrefix, java.lang.String isGetterPrefix, DefaultAccessorNamingStrategy.BaseNameValidator baseNameValidator)
-
-
Method Detail
-
findNameForIsGetter
public java.lang.String findNameForIsGetter(AnnotatedMethod am, java.lang.String name)
Description copied from class:AccessorNamingStrategyMethod 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.
- Specified by:
findNameForIsGetterin classAccessorNamingStrategy- Parameters:
am- Method to checkname- Name to check (usually same asAnnotatedMethod.getName()- Returns:
- Implied property name for is-getter method, if match;
nullto indicate that the name does not conform to expected naming convention
-
findNameForRegularGetter
public java.lang.String findNameForRegularGetter(AnnotatedMethod am, java.lang.String name)
Description copied from class:AccessorNamingStrategyMethod 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
AccessorNamingStrategy.findNameForIsGetter(com.fasterxml.jackson.databind.introspect.AnnotatedMethod, java.lang.String))Note that visibility checks are applied separately; strategy does not need to be concerned with that aspect.
- Specified by:
findNameForRegularGetterin classAccessorNamingStrategy- Parameters:
am- Method to checkname- Name to check (usually same asAnnotatedMethod.getName()- Returns:
- Implied property name for getter method, if match;
nullto indicate that the name does not conform to expected naming convention
-
findNameForMutator
public java.lang.String findNameForMutator(AnnotatedMethod am, java.lang.String name)
Description copied from class:AccessorNamingStrategyMethod 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.
- Specified by:
findNameForMutatorin classAccessorNamingStrategy- Parameters:
am- Method to checkname- Name to check (usually same asAnnotatedMethod.getName()- Returns:
- Implied property name for mutator method, if match;
nullto indicate that the name does not conform to expected naming convention
-
modifyFieldName
public java.lang.String modifyFieldName(AnnotatedField field, java.lang.String name)
Description copied from class:AccessorNamingStrategyMethod 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.
- Specified by:
modifyFieldNamein classAccessorNamingStrategy- Parameters:
field- Field to checkname- Name to check (usually same asAnnotatedField.getName()- Returns:
- Implied property name matching given field (often field name as-is) or
nullto indicate that the name does not conform to expected naming convention (and will not be considered for property access)
-
legacyManglePropertyName
protected java.lang.String legacyManglePropertyName(java.lang.String basename, int offset)Method called to figure out name of the property, given corresponding suggested name based on a method or field name.- Parameters:
basename- Name of accessor/mutator method, not including prefix ("get"/"is"/"set")
-
stdManglePropertyName
protected java.lang.String stdManglePropertyName(java.lang.String basename, int offset)
-
_isCglibGetCallbacks
protected boolean _isCglibGetCallbacks(AnnotatedMethod am)
-
_isGroovyMetaClassGetter
protected boolean _isGroovyMetaClassGetter(AnnotatedMethod am)
-
-