public class DefaultAccessorNamingStrategy extends AccessorNamingStrategy
AccessorNamingStrategy
used by Jackson: to be used either as-is,
or as base-class with overrides.Modifier and Type | Class and Description |
---|---|
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.
|
static class |
DefaultAccessorNamingStrategy.FirstCharBasedValidator
Simple implementation of
DefaultAccessorNamingStrategy.BaseNameValidator that checks the
first character and nothing else. |
static class |
DefaultAccessorNamingStrategy.Provider
Provider for
DefaultAccessorNamingStrategy . |
static class |
DefaultAccessorNamingStrategy.RecordNaming
Implementation used for supporting "non-prefix" naming convention of
Java 14
java.lang.Record types, and in particular find default
accessors for declared record fields. |
AccessorNamingStrategy.Base
Modifier and Type | Field and Description |
---|---|
protected DefaultAccessorNamingStrategy.BaseNameValidator |
_baseNameValidator
Optional validator for checking that base name
|
protected MapperConfig<?> |
_config |
protected AnnotatedClass |
_forClass |
protected String |
_getterPrefix |
protected String |
_isGetterPrefix |
protected boolean |
_isGettersNonBoolean |
protected String |
_mutatorPrefix
Prefix used by auto-detected mutators ("setters"): usually "set",
but differs for builder objects ("with" by default).
|
protected boolean |
_stdBeanNaming |
Modifier | Constructor and Description |
---|---|
protected |
DefaultAccessorNamingStrategy(MapperConfig<?> config,
AnnotatedClass forClass,
String mutatorPrefix,
String getterPrefix,
String isGetterPrefix,
DefaultAccessorNamingStrategy.BaseNameValidator baseNameValidator) |
Modifier and Type | Method and Description |
---|---|
protected boolean |
_isCglibGetCallbacks(AnnotatedMethod am) |
protected boolean |
_isGroovyMetaClassGetter(AnnotatedMethod am) |
String |
findNameForIsGetter(AnnotatedMethod am,
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)
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).
|
String |
findNameForMutator(AnnotatedMethod am,
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)
Note that signature acceptability has already been checked (exactly one parameter)
by caller.
|
String |
findNameForRegularGetter(AnnotatedMethod am,
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)
Note that signature acceptability has already been checked (no arguments,
does have a return value) by caller.
|
protected String |
legacyManglePropertyName(String basename,
int offset)
Method called to figure out name of the property, given
corresponding suggested name based on a method or field name.
|
String |
modifyFieldName(AnnotatedField field,
String name)
Method called to find the name of logical property that given field should
be associated with, if any.
|
protected String |
stdManglePropertyName(String basename,
int offset) |
protected final MapperConfig<?> _config
protected final AnnotatedClass _forClass
protected final DefaultAccessorNamingStrategy.BaseNameValidator _baseNameValidator
protected final boolean _stdBeanNaming
protected final boolean _isGettersNonBoolean
protected final String _getterPrefix
protected final String _isGetterPrefix
protected final String _mutatorPrefix
protected DefaultAccessorNamingStrategy(MapperConfig<?> config, AnnotatedClass forClass, String mutatorPrefix, String getterPrefix, String isGetterPrefix, DefaultAccessorNamingStrategy.BaseNameValidator baseNameValidator)
public String findNameForIsGetter(AnnotatedMethod am, String name)
AccessorNamingStrategy
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.
findNameForIsGetter
in class AccessorNamingStrategy
am
- Method to checkname
- Name to check (usually same as AnnotatedMethod.getName()
null
to indicate
that the name does not conform to expected naming conventionpublic String findNameForRegularGetter(AnnotatedMethod am, String name)
AccessorNamingStrategy
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.
findNameForRegularGetter
in class AccessorNamingStrategy
am
- Method to checkname
- Name to check (usually same as AnnotatedMethod.getName()
null
to indicate
that the name does not conform to expected naming conventionpublic String findNameForMutator(AnnotatedMethod am, String name)
AccessorNamingStrategy
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.
findNameForMutator
in class AccessorNamingStrategy
am
- Method to checkname
- Name to check (usually same as AnnotatedMethod.getName()
null
to indicate that the name does not conform to expected naming conventionpublic String modifyFieldName(AnnotatedField field, String name)
AccessorNamingStrategy
Note that visibility checks are applied separately; strategy does not need to be concerned with that aspect.
modifyFieldName
in class AccessorNamingStrategy
field
- Field to checkname
- Name to check (usually same as AnnotatedField.getName()
null
to indicate that the name does not conform to expected naming convention
(and will not be considered for property access)protected String legacyManglePropertyName(String basename, int offset)
basename
- Name of accessor/mutator method, not including prefix
("get"/"is"/"set")protected boolean _isCglibGetCallbacks(AnnotatedMethod am)
protected boolean _isGroovyMetaClassGetter(AnnotatedMethod am)
Copyright © 2008–2024 FasterXML. All rights reserved.