|
1 | 1 | package com.fasterxml.jackson.databind; |
2 | 2 |
|
3 | | -import java.util.logging.Logger; |
4 | | - |
5 | 3 | import com.fasterxml.jackson.databind.cfg.MapperConfig; |
6 | 4 | import com.fasterxml.jackson.databind.introspect.AnnotatedField; |
7 | 5 | import com.fasterxml.jackson.databind.introspect.AnnotatedMethod; |
|
36 | 34 | * Please use constants and classes in {@link PropertyNamingStrategies} instead. |
37 | 35 | * |
38 | 36 | */ |
39 | | -@SuppressWarnings("serial") |
40 | 37 | public class PropertyNamingStrategy // NOTE: was abstract until 2.7 |
41 | 38 | implements java.io.Serializable |
42 | 39 | { |
43 | 40 | private static final long serialVersionUID = 2L; |
44 | 41 |
|
45 | | - /** |
46 | | - * @deprecated Since 2.12 deprecated. Use {@link PropertyNamingStrategies#LOWER_CAMEL_CASE} instead. |
47 | | - * See |
48 | | - * <a href="https://github.com/FasterXML/jackson-databind/issues/2715">databind#2715</a> |
49 | | - * for reasons for deprecation. |
50 | | - */ |
51 | | - @Deprecated // since 2.12 |
52 | | - public static final PropertyNamingStrategy LOWER_CAMEL_CASE = new PropertyNamingStrategy(); |
| 42 | + // // Constants for standard implementations: removed from Jackson 2.20 |
53 | 43 |
|
54 | | - /** |
55 | | - * @deprecated Since 2.12 deprecated. Use {@link PropertyNamingStrategies#UPPER_CAMEL_CASE} instead. |
56 | | - * See |
57 | | - * <a href="https://github.com/FasterXML/jackson-databind/issues/2715">databind#2715</a> |
58 | | - * for reasons for deprecation. |
59 | | - */ |
60 | | - @Deprecated // since 2.12 |
61 | | - public static final PropertyNamingStrategy UPPER_CAMEL_CASE = new UpperCamelCaseStrategy(false); |
| 44 | + //@Deprecated // since 2.12 |
| 45 | + //public static final PropertyNamingStrategy LOWER_CAMEL_CASE = new PropertyNamingStrategy(); |
62 | 46 |
|
63 | | - /** |
64 | | - * @deprecated Since 2.12 deprecated. Use {@link PropertyNamingStrategies#SNAKE_CASE} instead. |
65 | | - * See |
66 | | - * <a href="https://github.com/FasterXML/jackson-databind/issues/2715">databind#2715</a> |
67 | | - * for reasons for deprecation. |
68 | | - */ |
69 | | - @Deprecated // since 2.12 |
70 | | - public static final PropertyNamingStrategy SNAKE_CASE = new SnakeCaseStrategy(false); |
| 47 | + //@Deprecated // since 2.12 |
| 48 | + //public static final PropertyNamingStrategy UPPER_CAMEL_CASE = new UpperCamelCaseStrategy(false); |
71 | 49 |
|
72 | | - /** |
73 | | - * @deprecated Since 2.12 deprecated. Use {@link PropertyNamingStrategies#LOWER_CASE} instead. |
74 | | - * See |
75 | | - * <a href="https://github.com/FasterXML/jackson-databind/issues/2715">databind#2715</a> |
76 | | - * for reasons for deprecation. |
77 | | - */ |
78 | | - @Deprecated // since 2.12 |
79 | | - public static final PropertyNamingStrategy LOWER_CASE = new LowerCaseStrategy(false); |
| 50 | + //@Deprecated // since 2.12 |
| 51 | + //public static final PropertyNamingStrategy SNAKE_CASE = new SnakeCaseStrategy(false); |
80 | 52 |
|
81 | | - /** |
82 | | - * @deprecated Since 2.12 deprecated. Use {@link PropertyNamingStrategies#KEBAB_CASE} instead. |
83 | | - * See |
84 | | - * <a href="https://github.com/FasterXML/jackson-databind/issues/2715">databind#2715</a> |
85 | | - * for reasons for deprecation. |
86 | | - */ |
87 | | - @Deprecated // since 2.12 |
88 | | - public static final PropertyNamingStrategy KEBAB_CASE = new KebabCaseStrategy(false); |
| 53 | + //@Deprecated // since 2.12 |
| 54 | + //public static final PropertyNamingStrategy LOWER_CASE = new LowerCaseStrategy(false); |
89 | 55 |
|
90 | | - /** |
91 | | - * @deprecated Since 2.12 deprecated. Use {@link PropertyNamingStrategies#LOWER_DOT_CASE} instead. |
92 | | - * See |
93 | | - * <a href="https://github.com/FasterXML/jackson-databind/issues/2715">databind#2715</a> |
94 | | - * for reasons for deprecation. |
95 | | - */ |
96 | | - @Deprecated // since 2.12 |
97 | | - public static final PropertyNamingStrategy LOWER_DOT_CASE = new LowerDotCaseStrategy(false); |
| 56 | + //@Deprecated // since 2.12 |
| 57 | + //public static final PropertyNamingStrategy KEBAB_CASE = new KebabCaseStrategy(false); |
| 58 | + |
| 59 | + //@Deprecated // since 2.12 |
| 60 | + //public static final PropertyNamingStrategy LOWER_DOT_CASE = new LowerDotCaseStrategy(false); |
98 | 61 |
|
99 | 62 | /* |
100 | 63 | /********************************************************** |
@@ -182,243 +145,36 @@ public String nameForConstructorParameter(MapperConfig<?> config, AnnotatedParam |
182 | 145 |
|
183 | 146 | /* |
184 | 147 | /********************************************************** |
185 | | - /* Public base class for simple implementations |
| 148 | + /* Public base class for simple implementations: removed from Jackson 2.20 |
186 | 149 | /********************************************************** |
187 | 150 | */ |
188 | 151 |
|
189 | | - /** |
| 152 | + /* |
190 | 153 | * @deprecated Since 2.12 deprecated. See |
191 | 154 | * <a href="https://github.com/FasterXML/jackson-databind/issues/2715">databind#2715</a> |
192 | 155 | * for reasons for deprecation. |
193 | 156 | */ |
194 | | - @Deprecated |
195 | | - public static abstract class PropertyNamingStrategyBase extends PropertyNamingStrategy |
196 | | - { |
197 | | - protected PropertyNamingStrategyBase() { |
198 | | - // For use via annotations: WARN |
199 | | - this(true); |
200 | | - } |
201 | | - |
202 | | - protected PropertyNamingStrategyBase(boolean logWarning) { |
203 | | - super(); |
204 | | - if (logWarning) { |
205 | | - final String simple = getClass().getSimpleName(); |
206 | | - Logger.getLogger(getClass().getName()) |
207 | | - .warning( |
208 | | -"PropertyNamingStrategy."+simple+" is used but it has been deprecated due to " + |
209 | | -"risk of deadlock. Consider using PropertyNamingStrategies."+simple+" instead. " + |
210 | | -"See https://github.com/FasterXML/jackson-databind/issues/2715 for more details."); |
211 | | - } |
212 | | - } |
213 | | - |
214 | | - @Override |
215 | | - public String nameForField(MapperConfig<?> config, AnnotatedField field, String defaultName) |
216 | | - { |
217 | | - return translate(defaultName); |
218 | | - } |
219 | | - |
220 | | - @Override |
221 | | - public String nameForGetterMethod(MapperConfig<?> config, AnnotatedMethod method, String defaultName) |
222 | | - { |
223 | | - return translate(defaultName); |
224 | | - } |
225 | | - |
226 | | - @Override |
227 | | - public String nameForSetterMethod(MapperConfig<?> config, AnnotatedMethod method, String defaultName) |
228 | | - { |
229 | | - return translate(defaultName); |
230 | | - } |
231 | | - |
232 | | - @Override |
233 | | - public String nameForConstructorParameter(MapperConfig<?> config, AnnotatedParameter ctorParam, |
234 | | - String defaultName) |
235 | | - { |
236 | | - return translate(defaultName); |
237 | | - } |
238 | | - |
239 | | - public abstract String translate(String propertyName); |
240 | | - |
241 | | - /** |
242 | | - * Helper method to share implementation between snake and dotted case. |
243 | | - */ |
244 | | - protected static String translateLowerCaseWithSeparator(final String input, final char separator) |
245 | | - { |
246 | | - if (input == null) { |
247 | | - return input; // garbage in, garbage out |
248 | | - } |
249 | | - final int length = input.length(); |
250 | | - if (length == 0) { |
251 | | - return input; |
252 | | - } |
253 | | - |
254 | | - final StringBuilder result = new StringBuilder(length + (length >> 1)); |
255 | | - int upperCount = 0; |
256 | | - for (int i = 0; i < length; ++i) { |
257 | | - char ch = input.charAt(i); |
258 | | - char lc = Character.toLowerCase(ch); |
259 | | - |
260 | | - if (lc == ch) { // lower-case letter means we can get new word |
261 | | - // but need to check for multi-letter upper-case (acronym), where assumption |
262 | | - // is that the last upper-case char is start of a new word |
263 | | - if (upperCount > 1) { |
264 | | - // so insert hyphen before the last character now |
265 | | - result.insert(result.length() - 1, separator); |
266 | | - } |
267 | | - upperCount = 0; |
268 | | - } else { |
269 | | - // Otherwise starts new word, unless beginning of string |
270 | | - if ((upperCount == 0) && (i > 0)) { |
271 | | - result.append(separator); |
272 | | - } |
273 | | - ++upperCount; |
274 | | - } |
275 | | - result.append(lc); |
276 | | - } |
277 | | - return result.toString(); |
278 | | - } |
279 | | - } |
| 157 | + //@Deprecated |
| 158 | + //public static abstract class PropertyNamingStrategyBase extends PropertyNamingStrategy |
280 | 159 |
|
281 | 160 | /* |
282 | 161 | /********************************************************** |
283 | | - /* Standard implementations |
| 162 | + /* Standard implementations: removed from Jackson 2.20 |
284 | 163 | /********************************************************** |
285 | 164 | */ |
286 | 165 |
|
287 | | - /** |
288 | | - * @deprecated Since 2.12 use {@link PropertyNamingStrategies.SnakeCaseStrategy} instead |
289 | | - * (see |
290 | | - * <a href="https://github.com/FasterXML/jackson-databind/issues/2715">databind#2715</a> |
291 | | - * for reason for deprecation) |
292 | | - */ |
293 | | - @Deprecated // since 2.12 |
294 | | - public static class SnakeCaseStrategy extends PropertyNamingStrategyBase |
295 | | - { |
296 | | - public SnakeCaseStrategy() { } |
297 | | - protected SnakeCaseStrategy(boolean logWarning) { super(logWarning); } |
298 | | - |
299 | | - @Override |
300 | | - public String translate(String input) |
301 | | - { |
302 | | - if (input == null) return input; // garbage in, garbage out |
303 | | - int length = input.length(); |
304 | | - StringBuilder result = new StringBuilder(length * 2); |
305 | | - int resultLength = 0; |
306 | | - boolean wasPrevTranslated = false; |
307 | | - for (int i = 0; i < length; i++) |
308 | | - { |
309 | | - char c = input.charAt(i); |
310 | | - if (i > 0 || c != '_') // skip first starting underscore |
311 | | - { |
312 | | - if (Character.isUpperCase(c)) |
313 | | - { |
314 | | - if (!wasPrevTranslated && resultLength > 0 && result.charAt(resultLength - 1) != '_') |
315 | | - { |
316 | | - result.append('_'); |
317 | | - resultLength++; |
318 | | - } |
319 | | - c = Character.toLowerCase(c); |
320 | | - wasPrevTranslated = true; |
321 | | - } |
322 | | - else |
323 | | - { |
324 | | - wasPrevTranslated = false; |
325 | | - } |
326 | | - result.append(c); |
327 | | - resultLength++; |
328 | | - } |
329 | | - } |
330 | | - return resultLength > 0 ? result.toString() : input; |
331 | | - } |
332 | | - } |
| 166 | + //@Deprecated // since 2.12 |
| 167 | + //public static class SnakeCaseStrategy extends PropertyNamingStrategyBase |
333 | 168 |
|
334 | | - /** |
335 | | - * @deprecated Since 2.12 use {@link PropertyNamingStrategies.UpperCamelCaseStrategy} instead |
336 | | - * (see |
337 | | - * <a href="https://github.com/FasterXML/jackson-databind/issues/2715">databind#2715</a> |
338 | | - * for reason for deprecation) |
339 | | - */ |
340 | | - @Deprecated // since 2.12 |
341 | | - public static class UpperCamelCaseStrategy extends PropertyNamingStrategyBase |
342 | | - { |
343 | | - public UpperCamelCaseStrategy() { } |
344 | | - protected UpperCamelCaseStrategy(boolean logWarning) { super(logWarning); } |
| 169 | + //@Deprecated // since 2.12 |
| 170 | + //public static class UpperCamelCaseStrategy extends PropertyNamingStrategyBase |
345 | 171 |
|
346 | | - /** |
347 | | - * Converts camelCase to PascalCase |
348 | | - * |
349 | | - * For example, "userName" would be converted to "UserName". |
350 | | - * |
351 | | - * @param input formatted as camelCase string |
352 | | - * @return input converted to PascalCase format |
353 | | - */ |
354 | | - @Override |
355 | | - public String translate(String input) { |
356 | | - if (input == null || input.isEmpty()){ |
357 | | - return input; // garbage in, garbage out |
358 | | - } |
359 | | - // Replace first lower-case letter with upper-case equivalent |
360 | | - char c = input.charAt(0); |
361 | | - char uc = Character.toUpperCase(c); |
362 | | - if (c == uc) { |
363 | | - return input; |
364 | | - } |
365 | | - StringBuilder sb = new StringBuilder(input); |
366 | | - sb.setCharAt(0, uc); |
367 | | - return sb.toString(); |
368 | | - } |
369 | | - } |
| 172 | + //@Deprecated // since 2.12 |
| 173 | + //public static class LowerCaseStrategy extends PropertyNamingStrategyBase |
370 | 174 |
|
371 | | - /** |
372 | | - * @deprecated Since 2.12 use {@link PropertyNamingStrategies.LowerCaseStrategy} instead |
373 | | - * (see |
374 | | - * <a href="https://github.com/FasterXML/jackson-databind/issues/2715">databind#2715</a> |
375 | | - * for reason for deprecation) |
376 | | - */ |
377 | | - @Deprecated // since 2.12 |
378 | | - public static class LowerCaseStrategy extends PropertyNamingStrategyBase |
379 | | - { |
380 | | - public LowerCaseStrategy() { } |
381 | | - protected LowerCaseStrategy(boolean logWarning) { super(logWarning); } |
382 | | - |
383 | | - @Override |
384 | | - public String translate(String input) { |
385 | | - return input.toLowerCase(); |
386 | | - } |
387 | | - } |
388 | | - |
389 | | - /** |
390 | | - * @deprecated Since 2.12 use {@link PropertyNamingStrategies.KebabCaseStrategy} instead |
391 | | - * (see |
392 | | - * <a href="https://github.com/FasterXML/jackson-databind/issues/2715">databind#2715</a> |
393 | | - * for reason for deprecation) |
394 | | - */ |
395 | | - @Deprecated // since 2.12 |
396 | | - public static class KebabCaseStrategy extends PropertyNamingStrategyBase |
397 | | - { |
398 | | - public KebabCaseStrategy() { } |
399 | | - protected KebabCaseStrategy(boolean logWarning) { super(logWarning); } |
| 175 | + //@Deprecated // since 2.12 |
| 176 | + //public static class KebabCaseStrategy extends PropertyNamingStrategyBase |
400 | 177 |
|
401 | | - @Override |
402 | | - public String translate(String input) { |
403 | | - return translateLowerCaseWithSeparator(input, '-'); |
404 | | - } |
405 | | - } |
406 | | - |
407 | | - /** |
408 | | - * @deprecated Since 2.12 use {@link PropertyNamingStrategies.LowerDotCaseStrategy} instead |
409 | | - * (see |
410 | | - * <a href="https://github.com/FasterXML/jackson-databind/issues/2715">databind#2715</a> |
411 | | - * for reason for deprecation) |
412 | | - */ |
413 | | - @Deprecated // since 2.12 |
414 | | - public static class LowerDotCaseStrategy extends PropertyNamingStrategyBase |
415 | | - { |
416 | | - public LowerDotCaseStrategy() { } |
417 | | - protected LowerDotCaseStrategy(boolean logWarning) { super(logWarning); } |
418 | | - |
419 | | - @Override |
420 | | - public String translate(String input){ |
421 | | - return translateLowerCaseWithSeparator(input, '.'); |
422 | | - } |
423 | | - } |
| 178 | + //@Deprecated // since 2.12 |
| 179 | + //public static class LowerDotCaseStrategy extends PropertyNamingStrategyBase |
424 | 180 | } |
0 commit comments