21
21
public class JDKArraySerializers
22
22
{
23
23
protected final static HashMap <String , ValueSerializer <?>> _arraySerializers =
24
- new HashMap <String , ValueSerializer <?> >();
24
+ new HashMap <>();
25
25
static {
26
26
// Arrays of various types (including common object types)
27
- _arraySerializers .put (boolean [].class .getName (), new JDKArraySerializers . BooleanArraySerializer ());
27
+ _arraySerializers .put (boolean [].class .getName (), new BooleanArraySerializer ());
28
28
_arraySerializers .put (byte [].class .getName (), new ByteArraySerializer ());
29
- _arraySerializers .put (char [].class .getName (), new JDKArraySerializers . CharArraySerializer ());
30
- _arraySerializers .put (short [].class .getName (), new JDKArraySerializers . ShortArraySerializer ());
31
- _arraySerializers .put (int [].class .getName (), new JDKArraySerializers . IntArraySerializer ());
32
- _arraySerializers .put (long [].class .getName (), new JDKArraySerializers . LongArraySerializer ());
33
- _arraySerializers .put (float [].class .getName (), new JDKArraySerializers . FloatArraySerializer ());
34
- _arraySerializers .put (double [].class .getName (), new JDKArraySerializers . DoubleArraySerializer ());
29
+ _arraySerializers .put (char [].class .getName (), new CharArraySerializer ());
30
+ _arraySerializers .put (short [].class .getName (), new ShortArraySerializer ());
31
+ _arraySerializers .put (int [].class .getName (), new IntArraySerializer ());
32
+ _arraySerializers .put (long [].class .getName (), new LongArraySerializer ());
33
+ _arraySerializers .put (float [].class .getName (), new FloatArraySerializer ());
34
+ _arraySerializers .put (double [].class .getName (), new DoubleArraySerializer ());
35
35
}
36
36
37
37
protected JDKArraySerializers () { }
@@ -44,6 +44,12 @@ public static ValueSerializer<?> findStandardImpl(Class<?> cls) {
44
44
return _arraySerializers .get (cls .getName ());
45
45
}
46
46
47
+ // @since 2.19
48
+ @ SuppressWarnings ("deprecation" )
49
+ static JavaType simpleElementType (Class <?> elemClass ) {
50
+ return TypeFactory .defaultInstance ().uncheckedSimpleType (elemClass );
51
+ }
52
+
47
53
/*
48
54
****************************************************************
49
55
/* Intermediate base classes
@@ -86,8 +92,7 @@ public static class BooleanArraySerializer
86
92
extends ArraySerializerBase <boolean []>
87
93
{
88
94
// as above, assuming no one re-defines primitive/wrapper types
89
- @ SuppressWarnings ("deprecation" )
90
- private final static JavaType VALUE_TYPE = TypeFactory .defaultInstance ().uncheckedSimpleType (Boolean .class );
95
+ private final static JavaType VALUE_TYPE = simpleElementType (Boolean .TYPE );
91
96
92
97
public BooleanArraySerializer () { super (boolean [].class ); }
93
98
@@ -164,8 +169,7 @@ public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType t
164
169
public static class ShortArraySerializer extends TypedPrimitiveArraySerializer <short []>
165
170
{
166
171
// as above, assuming no one re-defines primitive/wrapper types
167
- @ SuppressWarnings ("deprecation" )
168
- private final static JavaType VALUE_TYPE = TypeFactory .defaultInstance ().uncheckedSimpleType (Short .TYPE );
172
+ private final static JavaType VALUE_TYPE = simpleElementType (Short .TYPE );
169
173
170
174
public ShortArraySerializer () { super (short [].class ); }
171
175
public ShortArraySerializer (ShortArraySerializer src , BeanProperty prop ,
@@ -298,8 +302,7 @@ public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType t
298
302
public static class IntArraySerializer extends ArraySerializerBase <int []>
299
303
{
300
304
// as above, assuming no one re-defines primitive/wrapper types
301
- @ SuppressWarnings ("deprecation" )
302
- private final static JavaType VALUE_TYPE = TypeFactory .defaultInstance ().uncheckedSimpleType (Integer .TYPE );
305
+ private final static JavaType VALUE_TYPE = simpleElementType (Integer .TYPE );
303
306
304
307
public IntArraySerializer () { super (int [].class ); }
305
308
@@ -375,8 +378,7 @@ public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType t
375
378
public static class LongArraySerializer extends TypedPrimitiveArraySerializer <long []>
376
379
{
377
380
// as above, assuming no one re-defines primitive/wrapper types
378
- @ SuppressWarnings ("deprecation" )
379
- private final static JavaType VALUE_TYPE = TypeFactory .defaultInstance ().uncheckedSimpleType (Long .TYPE );
381
+ private final static JavaType VALUE_TYPE = simpleElementType (Long .TYPE );
380
382
381
383
public LongArraySerializer () { super (long [].class ); }
382
384
public LongArraySerializer (LongArraySerializer src , BeanProperty prop ,
@@ -442,8 +444,7 @@ public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType t
442
444
public static class FloatArraySerializer extends TypedPrimitiveArraySerializer <float []>
443
445
{
444
446
// as above, assuming no one re-defines primitive/wrapper types
445
- @ SuppressWarnings ("deprecation" )
446
- private final static JavaType VALUE_TYPE = TypeFactory .defaultInstance ().uncheckedSimpleType (Float .TYPE );
447
+ private final static JavaType VALUE_TYPE = simpleElementType (Float .TYPE );
447
448
448
449
public FloatArraySerializer () {
449
450
super (float [].class );
@@ -512,8 +513,7 @@ public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType t
512
513
public static class DoubleArraySerializer extends ArraySerializerBase <double []>
513
514
{
514
515
// as above, assuming no one re-defines primitive/wrapper types
515
- @ SuppressWarnings ("deprecation" )
516
- private final static JavaType VALUE_TYPE = TypeFactory .defaultInstance ().uncheckedSimpleType (Double .TYPE );
516
+ private final static JavaType VALUE_TYPE = simpleElementType (Double .TYPE );
517
517
518
518
public DoubleArraySerializer () { super (double [].class ); }
519
519
0 commit comments