Top Description Fields Constructors Methods
tools.jackson.databind

public Class PropertyNamingStrategy

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Known Direct Subclasses
tools.jackson.databind.PropertyNamingStrategies.NamingBase
Imports
tools.jackson.databind.cfg.MapperConfig, tools.jackson.databind.introspect.AnnotatedField, .AnnotatedMethod, .AnnotatedParameter

Class that defines how names of JSON properties ("external names") are derived from names of POJO methods and fields ("internal names"), in cases where no explicit annotations exist for naming. Methods are passed information about POJO member for which name is needed, as well as default name that would be used if no custom strategy was used.

Default (empty) implementation returns suggested ("implicit" or "default") name unmodified

Note that the strategy is guaranteed to be called once per logical property (which may be represented by multiple members; such as pair of a getter and a setter), but may be called for each: implementations should not count on exact number of times, and should work for any member that represent a property. Also note that calls are made during construction of serializers and deserializers which are typically cached, and not for every time serializer or deserializer is called.

In absence of a registered custom strategy, the default Java property naming strategy is used, which leaves field names as is, and removes set/get/is prefix from methods (as well as lower-cases initial sequence of capitalized characters).

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
nameForConstructorParameter(MapperConfig<?>
Configuration in used: either SerializationConfig or DeserializationConfig, depending on whether method is called during serialization or deserialization
config
,
AnnotatedParameter
Constructor parameter used to pass property.
ctorParam
,
String
Default name that would be used for property in absence of custom strategy
defaultName
)

Method called to find external name (name used in JSON) for given logical POJO property, as defined by given constructor parameter; typically called when building a deserializer (but not necessarily only then).

public String

Returns:

Logical name to use for property that the field represents
nameForField
(MapperConfig<?>
Configuration in used: either SerializationConfig or DeserializationConfig, depending on whether method is called during serialization or deserialization
config
,
AnnotatedField
Field used to access property
field
,
String
Default name that would be used for property in absence of custom strategy
defaultName
)

Method called to find external name (name used in JSON) for given logical POJO property, as defined by given field.

public String

Returns:

Logical name to use for property that the method represents
nameForGetterMethod
(MapperConfig<?>
Configuration in used: either SerializationConfig or DeserializationConfig, depending on whether method is called during serialization or deserialization
config
,
AnnotatedMethod
Method used to access property.
method
,
String
Default name that would be used for property in absence of custom strategy
defaultName
)

Method called to find external name (name used in JSON) for given logical POJO property, as defined by given getter method; typically called when building a serializer.

public String

Returns:

Logical name to use for property that the method represents
nameForSetterMethod
(MapperConfig<?>
Configuration in used: either SerializationConfig or DeserializationConfig, depending on whether method is called during serialization or deserialization
config
,
AnnotatedMethod
Method used to access property.
method
,
String
Default name that would be used for property in absence of custom strategy
defaultName
)

Method called to find external name (name used in JSON) for given logical POJO property, as defined by given setter method; typically called when building a deserializer (but not necessarily only then).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

PropertyNamingStrategyback to summary
public PropertyNamingStrategy()

Method Detail

nameForConstructorParameterback to summary
public String nameForConstructorParameter(MapperConfig<?> config, AnnotatedParameter ctorParam, String defaultName)

Method called to find external name (name used in JSON) for given logical POJO property, as defined by given constructor parameter; typically called when building a deserializer (but not necessarily only then).

Parameters
config:MapperConfig<?>

Configuration in used: either SerializationConfig or DeserializationConfig, depending on whether method is called during serialization or deserialization

ctorParam:AnnotatedParameter

Constructor parameter used to pass property.

defaultName:String

Default name that would be used for property in absence of custom strategy

nameForFieldback to summary
public String nameForField(MapperConfig<?> config, AnnotatedField field, String defaultName)

Method called to find external name (name used in JSON) for given logical POJO property, as defined by given field.

Parameters
config:MapperConfig<?>

Configuration in used: either SerializationConfig or DeserializationConfig, depending on whether method is called during serialization or deserialization

field:AnnotatedField

Field used to access property

defaultName:String

Default name that would be used for property in absence of custom strategy

Returns:String

Logical name to use for property that the field represents

nameForGetterMethodback to summary
public String nameForGetterMethod(MapperConfig<?> config, AnnotatedMethod method, String defaultName)

Method called to find external name (name used in JSON) for given logical POJO property, as defined by given getter method; typically called when building a serializer. (but not always -- when using "getter-as-setter", may be called during deserialization)

Parameters
config:MapperConfig<?>

Configuration in used: either SerializationConfig or DeserializationConfig, depending on whether method is called during serialization or deserialization

method:AnnotatedMethod

Method used to access property.

defaultName:String

Default name that would be used for property in absence of custom strategy

Returns:String

Logical name to use for property that the method represents

nameForSetterMethodback to summary
public String nameForSetterMethod(MapperConfig<?> config, AnnotatedMethod method, String defaultName)

Method called to find external name (name used in JSON) for given logical POJO property, as defined by given setter method; typically called when building a deserializer (but not necessarily only then).

Parameters
config:MapperConfig<?>

Configuration in used: either SerializationConfig or DeserializationConfig, depending on whether method is called during serialization or deserialization

method:AnnotatedMethod

Method used to access property.

defaultName:String

Default name that would be used for property in absence of custom strategy

Returns:String

Logical name to use for property that the method represents