16
16
17
17
/**
18
18
* Container class for serializers used for handling standard JDK-provided
19
- * types.
19
+ * primitve number types and their wrapper counterparts (like {@link java.lang.Integer}) .
20
20
*/
21
21
@ SuppressWarnings ("serial" )
22
22
public class NumberSerializers {
@@ -46,8 +46,19 @@ public static void addAll(Map<String, JsonSerializer<?>> allDeserializers) {
46
46
/**********************************************************
47
47
*/
48
48
49
- protected abstract static class Base <T > extends StdScalarSerializer <T >
50
- implements ContextualSerializer {
49
+ /**
50
+ * Shared base class for actual primitive/wrapper number serializers.
51
+ * Note that this class is not meant as general-purpose base class nor
52
+ * is it part of public API: you may extend it with the caveat that not
53
+ * being part of public API its implementation and interfaces may change
54
+ * in minor releases; however deprecation markers will be used to allow
55
+ * code evolution.
56
+ *<p>
57
+ * NOTE: {@code public} since 2.10: previously had {@code protected} access.
58
+ */
59
+ public abstract static class Base <T > extends StdScalarSerializer <T >
60
+ implements ContextualSerializer
61
+ {
51
62
protected final JsonParser .NumberType _numberType ;
52
63
protected final String _schemaType ;
53
64
protected final boolean _isInt ;
@@ -101,7 +112,7 @@ public JsonSerializer<?> createContextual(SerializerProvider prov,
101
112
*/
102
113
103
114
@ JacksonStdImpl
104
- public final static class ShortSerializer extends Base <Object > {
115
+ public static class ShortSerializer extends Base <Object > {
105
116
final static ShortSerializer instance = new ShortSerializer ();
106
117
107
118
public ShortSerializer () {
@@ -119,14 +130,14 @@ public void serialize(Object value, JsonGenerator gen,
119
130
* This is the special serializer for regular {@link java.lang.Integer}s
120
131
* (and primitive ints)
121
132
* <p>
122
- * Since this is one of "native " types, no type information is ever included
123
- * on serialization (unlike for most scalar types)
133
+ * Since this is one of "natural " types, no type information is ever included
134
+ * on serialization (unlike for most scalar types, except for {@code double}.
124
135
* <p>
125
136
* NOTE: as of 2.6, generic signature changed to Object, to avoid generation
126
137
* of bridge methods.
127
138
*/
128
139
@ JacksonStdImpl
129
- public final static class IntegerSerializer extends Base <Object > {
140
+ public static class IntegerSerializer extends Base <Object > {
130
141
public IntegerSerializer (Class <?> type ) {
131
142
super (type , JsonParser .NumberType .INT , "integer" );
132
143
}
@@ -153,7 +164,7 @@ public void serializeWithType(Object value, JsonGenerator gen,
153
164
* calling {@link java.lang.Number#intValue}.
154
165
*/
155
166
@ JacksonStdImpl
156
- public final static class IntLikeSerializer extends Base <Object > {
167
+ public static class IntLikeSerializer extends Base <Object > {
157
168
final static IntLikeSerializer instance = new IntLikeSerializer ();
158
169
159
170
public IntLikeSerializer () {
@@ -168,7 +179,7 @@ public void serialize(Object value, JsonGenerator gen,
168
179
}
169
180
170
181
@ JacksonStdImpl
171
- public final static class LongSerializer extends Base <Object > {
182
+ public static class LongSerializer extends Base <Object > {
172
183
public LongSerializer (Class <?> cls ) {
173
184
super (cls , JsonParser .NumberType .LONG , "number" );
174
185
}
@@ -181,7 +192,7 @@ public void serialize(Object value, JsonGenerator gen,
181
192
}
182
193
183
194
@ JacksonStdImpl
184
- public final static class FloatSerializer extends Base <Object > {
195
+ public static class FloatSerializer extends Base <Object > {
185
196
final static FloatSerializer instance = new FloatSerializer ();
186
197
187
198
public FloatSerializer () {
@@ -200,10 +211,10 @@ public void serialize(Object value, JsonGenerator gen,
200
211
* primitive doubles)
201
212
* <p>
202
213
* Since this is one of "native" types, no type information is ever included
203
- * on serialization (unlike for most scalar types as of 1.5)
214
+ * on serialization (unlike for most scalar types other than {@code long}).
204
215
*/
205
216
@ JacksonStdImpl
206
- public final static class DoubleSerializer extends Base <Object > {
217
+ public static class DoubleSerializer extends Base <Object > {
207
218
public DoubleSerializer (Class <?> cls ) {
208
219
super (cls , JsonParser .NumberType .DOUBLE , "number" );
209
220
}
0 commit comments