Package com.fasterxml.jackson.databind
Class EnumNamingStrategies.CamelCaseStrategy
- java.lang.Object
-
- com.fasterxml.jackson.databind.EnumNamingStrategies.CamelCaseStrategy
-
- All Implemented Interfaces:
EnumNamingStrategy
- Enclosing class:
- EnumNamingStrategies
public static class EnumNamingStrategies.CamelCaseStrategy extends java.lang.Object implements EnumNamingStrategy
An implementation of
EnumNamingStrategy
that converts enum names in the typical upper snake case format to camel case format. This implementation follows three rules described below.- converts any character preceded by an underscore into upper case character, regardless of its original case (upper or lower).
- converts any character NOT preceded by an underscore into a lower case character, regardless of its original case (upper or lower).
- converts contiguous sequence of underscores into a single underscore.
PEANUT_BUTTER
,PEANUT__BUTTER
are converted into "peanutButter". And "peanutButter" will be deserialized into enum with smallerEnum.ordinal()
value.These rules result in the following example conversions from upper snakecase names to camelcase names.
- "USER_NAME" is converted into "userName"
- "USER______NAME" is converted into "userName"
- "USERNAME" is converted into "username"
- "User__Name" is converted into "userName"
- "_user_name" is converted into "UserName"
- "_user_name_s" is converted into "UserNameS"
- "__Username" is converted into "Username"
- "__username" is converted into "Username"
- "username" is converted into "username"
- "Username" is converted into "username"
- Since:
- 2.15
-
-
Field Summary
Fields Modifier and Type Field Description static EnumNamingStrategies.CamelCaseStrategy
INSTANCE
An intance ofEnumNamingStrategies.CamelCaseStrategy
for reuse.
-
Constructor Summary
Constructors Constructor Description CamelCaseStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
convertEnumToExternalName(java.lang.String enumName)
Translates the givenenumName
into an external property name according to the implementation of thisEnumNamingStrategy
.
-
-
-
Field Detail
-
INSTANCE
public static final EnumNamingStrategies.CamelCaseStrategy INSTANCE
An intance ofEnumNamingStrategies.CamelCaseStrategy
for reuse.- Since:
- 2.15
-
-
Method Detail
-
convertEnumToExternalName
public java.lang.String convertEnumToExternalName(java.lang.String enumName)
Description copied from interface:EnumNamingStrategy
Translates the givenenumName
into an external property name according to the implementation of thisEnumNamingStrategy
.- Specified by:
convertEnumToExternalName
in interfaceEnumNamingStrategy
- Parameters:
enumName
- the name of the enum value to translate- Returns:
- the external property name that corresponds to the given
enumName
according to the implementation of thisEnumNamingStrategy
. - Since:
- 2.15
-
-