4
4
import java .util .Locale ;
5
5
import java .util .TimeZone ;
6
6
7
+ import com .fasterxml .jackson .annotation .JsonFormat .Shape ;
8
+
7
9
/**
8
10
* General-purpose annotation used for configuring details of how
9
11
* values of properties are to be serialized and deserialized.
17
19
* or String (such as ISO-8601 compatible time value) -- as well as configuring
18
20
* exact details with {@link #pattern} property.
19
21
*<p>
20
- * As of Jackson 2.18 , known special handling includes:
22
+ * As of Jackson 2.19 , known special handling includes:
21
23
*<ul>
22
24
* <li>{@link java.util.Date} or {@link java.util.Calendar}: Shape can be {@link Shape#STRING} or {@link Shape#NUMBER};
23
25
* pattern may contain {@link java.text.SimpleDateFormat}-compatible pattern definition.
152
154
*/
153
155
public enum Shape
154
156
{
157
+ // // // Concrete physical shapes, scalars
155
158
/**
156
- * Marker enum value that indicates "whatever" choice, meaning that annotation
157
- * does NOT specify shape to use.
158
- * Note that this is different from {@link Shape#NATURAL}, which
159
- * specifically instructs use of the "natural" shape for datatype.
160
- */
161
- ANY ,
162
-
163
- /**
164
- * Marker enum value that indicates the "default" choice for given datatype;
165
- * for example, JSON String for {@link java.lang.String}, or JSON Number
166
- * for Java numbers.
167
- * Note that this is different from {@link Shape#ANY} in that this is actual
168
- * explicit choice that overrides possible default settings.
159
+ * Value that indicates that Binary type (native, if format supports it;
160
+ * encoding using Base64 if only textual types supported) should be used.
169
161
*
170
- * @since 2.8
171
- */
172
- NATURAL ,
173
-
174
- /**
175
- * Value that indicates shape should not be structural (that is, not
176
- * {@link #ARRAY} or {@link #OBJECT}), but can be any other shape.
177
- */
178
- SCALAR ,
179
-
180
- /**
181
- * Value that indicates that (JSON) Array type should be used.
162
+ * @since 2.10
182
163
*/
183
- ARRAY ,
164
+ BINARY ,
184
165
185
166
/**
186
- * Value that indicates that (JSON) Object type should be used.
167
+ * Value that indicates that (JSON) boolean type
168
+ * (true, false) should be used.
187
169
*/
188
- OBJECT ,
170
+ BOOLEAN ,
189
171
190
172
/**
191
173
* Value that indicates that a numeric (JSON) type should be used
@@ -211,26 +193,71 @@ public enum Shape
211
193
STRING ,
212
194
213
195
/**
214
- * Value that indicates that (JSON) boolean type
215
- * (true, false) should be used .
196
+ * Value that indicates shape should not be structural (that is, not
197
+ * {@link #ARRAY} or {@link #OBJECT}), but can be any other shape .
216
198
*/
217
- BOOLEAN ,
199
+ SCALAR ,
200
+
201
+ // // // Concrete physical shapes, structured
218
202
219
203
/**
220
- * Value that indicates that Binary type (native, if format supports it;
221
- * encoding using Base64 if only textual types supported) should be used.
204
+ * Value that indicates that (JSON) Array type should be used.
205
+ */
206
+ ARRAY ,
207
+
208
+ /**
209
+ * Value that indicates that (JSON) Object type should be used.
210
+ */
211
+ OBJECT ,
212
+
213
+ // // // Additional logical meta-types
214
+
215
+ /**
216
+ * Marker enum value that indicates "whatever" choice, meaning that annotation
217
+ * does NOT specify shape to use.
218
+ * Note that this is different from {@link Shape#NATURAL}, which
219
+ * specifically instructs use of the "natural" shape for datatype.
220
+ */
221
+ ANY ,
222
+
223
+ /**
224
+ * Marker enum value that indicates the "default" choice for given datatype;
225
+ * for example, JSON String for {@link java.lang.String}, or JSON Number
226
+ * for Java numbers.
227
+ * Note that this is different from {@link Shape#ANY} in that this is actual
228
+ * explicit choice that overrides possible default settings.
222
229
*
223
- * @since 2.10
230
+ * @since 2.8
231
+ */
232
+ NATURAL ,
233
+
234
+ /**
235
+ * Marker enum value that indicates not only shape of {@link #OBJECT} but further
236
+ * handling as POJO, where applicable. Mostly makes difference at Java Object level
237
+ * when distinguishing handling between {@link java.util.Map} and POJO types.
238
+ *
239
+ * @since 2.20
224
240
*/
225
- BINARY
241
+ POJO ,
242
+
226
243
;
227
244
228
245
public boolean isNumeric () {
229
246
return (this == NUMBER ) || (this == NUMBER_INT ) || (this == NUMBER_FLOAT );
230
247
}
231
248
249
+ /** @since 2.20 */
250
+ public static boolean isNumeric (Shape shapeOrNull ) {
251
+ return (shapeOrNull != null ) && shapeOrNull .isNumeric ();
252
+ }
253
+
232
254
public boolean isStructured () {
233
- return (this == OBJECT ) || (this == ARRAY );
255
+ return (this == OBJECT ) || (this == ARRAY ) || (this == POJO );
256
+ }
257
+
258
+ /** @since 2.20 */
259
+ public static boolean isStructured (Shape shapeOrNull ) {
260
+ return (shapeOrNull != null ) && shapeOrNull .isStructured ();
234
261
}
235
262
}
236
263
@@ -541,20 +568,6 @@ public Value(String p, Shape sh, Locale l, String tzStr, TimeZone tz, Features f
541
568
_lenient = lenient ;
542
569
}
543
570
544
- @ Deprecated // since 2.9
545
- public Value (String p , Shape sh , Locale l , String tzStr , TimeZone tz , Features f ) {
546
- this (p , sh , l , tzStr , tz , f , null );
547
- }
548
-
549
- @ Deprecated // since 2.9
550
- public Value (String p , Shape sh , String localeStr , String tzStr , Features f ) {
551
- this (p , sh , localeStr , tzStr , f , null );
552
- }
553
- @ Deprecated // since 2.9
554
- public Value (String p , Shape sh , Locale l , TimeZone tz , Features f ) {
555
- this (p , sh , l , tz , f , null );
556
- }
557
-
558
571
/**
559
572
* @since 2.7
560
573
*/
0 commit comments