|
27 | 27 | * characters).
|
28 | 28 | */
|
29 | 29 | @SuppressWarnings("serial")
|
30 |
| -public abstract class PropertyNamingStrategy |
| 30 | +public class PropertyNamingStrategy // NOTE: was abstract until 2.7 |
31 | 31 | implements java.io.Serializable
|
32 | 32 | {
|
33 | 33 | /**
|
34 |
| - * See {@link LowerCaseWithUnderscoresStrategy} for details. |
| 34 | + * Naming convention used in languages like C, where words are in lower-case |
| 35 | + * letters, separated by underscores. |
| 36 | + * See {@link SnakeCaseStrategy} for details. |
| 37 | + * |
| 38 | + * @since 2.7 (was formerly called {@link #CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES}) |
35 | 39 | */
|
36 |
| - public static final PropertyNamingStrategy CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES = |
37 |
| - new LowerCaseWithUnderscoresStrategy(); |
| 40 | + public static final PropertyNamingStrategy SNAKE_CASE = new SnakeCaseStrategy(); |
38 | 41 |
|
39 | 42 | /**
|
| 43 | + * Naming convention used in languages like Pascal, where words are capitalized |
| 44 | + * and no separator is used between words. |
40 | 45 | * See {@link PascalCaseStrategy} for details.
|
41 |
| - * |
42 |
| - * @since 2.1 |
| 46 | + * |
| 47 | + * @since 2.7 (was formerly called {@link #PASCAL_CASE_TO_CAMEL_CASE}) |
43 | 48 | */
|
44 |
| - public static final PropertyNamingStrategy PASCAL_CASE_TO_CAMEL_CASE = |
45 |
| - new PascalCaseStrategy(); |
| 49 | + public static final PropertyNamingStrategy UPPER_CAMEL_CASE = new UpperCamelCaseStrategy(); |
46 | 50 |
|
47 | 51 | /**
|
| 52 | + * Naming convention used in Java, where words other than first are capitalized |
| 53 | + * and no separator is used between words. Since this is the native Java naming convention, |
| 54 | + * naming strategy will not do any transformation between names in data (JSON) and |
| 55 | + * POJOS. |
| 56 | + * |
| 57 | + * @since 2.7 (was formerly called {@link #PASCAL_CASE_TO_CAMEL_CASE}) |
| 58 | + */ |
| 59 | + public static final PropertyNamingStrategy LOWER_CAMEL_CASE = new PropertyNamingStrategy(); |
| 60 | + |
| 61 | + /** |
| 62 | + * Naming convention in which all words of the logical name are in lower case, and |
| 63 | + * no separator is used between words. |
48 | 64 | * See {@link LowerCaseStrategy} for details.
|
49 | 65 | *
|
50 | 66 | * @since 2.4
|
@@ -226,8 +242,10 @@ public String nameForConstructorParameter(MapperConfig<?> config, AnnotatedParam
|
226 | 242 | * (the first of two underscores was removed)</li>
|
227 | 243 | * <li>"user__name" is translated to "user__name"
|
228 | 244 | * (unchanged, with two underscores)</li></ul>
|
| 245 | + * |
| 246 | + * @since 2.7 (was previously called } |
229 | 247 | */
|
230 |
| - public static class LowerCaseWithUnderscoresStrategy extends PropertyNamingStrategyBase |
| 248 | + public static class SnakeCaseStrategy extends PropertyNamingStrategyBase |
231 | 249 | {
|
232 | 250 | @Override
|
233 | 251 | public String translate(String input)
|
@@ -277,9 +295,9 @@ public String translate(String input)
|
277 | 295 | * Java property names to JSON element names.
|
278 | 296 | * <ul><li>"userName" is translated to "UserName"</li></ul>
|
279 | 297 | *
|
280 |
| - * @since 2.1 |
| 298 | + * @since 2.7 (was formerly called {@link PascalCaseStrategy}) |
281 | 299 | */
|
282 |
| - public static class PascalCaseStrategy extends PropertyNamingStrategyBase |
| 300 | + public static class UpperCamelCaseStrategy extends PropertyNamingStrategyBase |
283 | 301 | {
|
284 | 302 | /**
|
285 | 303 | * Converts camelCase to PascalCase
|
@@ -322,4 +340,35 @@ public String translate(String input) {
|
322 | 340 | return input.toLowerCase();
|
323 | 341 | }
|
324 | 342 | }
|
| 343 | + |
| 344 | + /* |
| 345 | + /********************************************************** |
| 346 | + /* Deprecated variants, aliases |
| 347 | + /********************************************************** |
| 348 | + */ |
| 349 | + |
| 350 | + /** |
| 351 | + * @deprecated Since 2.7 use {@link #SNAKE_CASE} instead; |
| 352 | + */ |
| 353 | + @Deprecated // since 2.7 |
| 354 | + public static final PropertyNamingStrategy CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES = SNAKE_CASE; |
| 355 | + |
| 356 | + /** |
| 357 | + * @deprecated Since 2.7 use {@link #UPPER_CAMEL_CASE} instead; |
| 358 | + */ |
| 359 | + @Deprecated // since 2.7 |
| 360 | + public static final PropertyNamingStrategy PASCAL_CASE_TO_CAMEL_CASE = UPPER_CAMEL_CASE; |
| 361 | + |
| 362 | + /** |
| 363 | + * @deprecated In 2.7 use {@link SnakeCaseStrategy} instead |
| 364 | + */ |
| 365 | + @Deprecated |
| 366 | + public static class LowerCaseWithUnderscoresStrategy extends SnakeCaseStrategy {} |
| 367 | + |
| 368 | + /** |
| 369 | + * @deprecated In 2.7 use {@link SnakeCaseStrategy} instead |
| 370 | + */ |
| 371 | + @Deprecated |
| 372 | + public static class PascalCaseStrategy extends UpperCamelCaseStrategy {} |
325 | 373 | }
|
| 374 | + |
0 commit comments