1
1
package tools .jackson .databind .cfg ;
2
2
3
- import tools .jackson .databind .SerializationFeature ;
3
+ import tools .jackson .databind .DeserializationFeature ;
4
4
5
5
/**
6
6
* New Datatype-specific configuration options related to handling of
@@ -14,7 +14,7 @@ public enum EnumFeature implements DatatypeFeature
14
14
* index of <code>Enum</code>;
15
15
*<p>
16
16
* Note: this feature should be symmetric to
17
- * as {@link SerializationFeature #WRITE_ENUM_KEYS_USING_INDEX}.
17
+ * as {@link #WRITE_ENUM_KEYS_USING_INDEX}.
18
18
*<p>
19
19
* Feature is disabled by default.
20
20
*
@@ -34,7 +34,63 @@ public enum EnumFeature implements DatatypeFeature
34
34
*
35
35
* @since 2.15
36
36
*/
37
- WRITE_ENUMS_TO_LOWERCASE (false );
37
+ WRITE_ENUMS_TO_LOWERCASE (false ),
38
+
39
+
40
+ /**
41
+ * Feature that determines standard serialization mechanism used for
42
+ * Enum values: if enabled, return value of <code>Enum.toString()</code>
43
+ * is used; if disabled, return value of <code>Enum.name()</code> is used.
44
+ *<p>
45
+ * Note: this feature should usually have same value
46
+ * as {@link DeserializationFeature#READ_ENUMS_USING_TO_STRING}.
47
+ *<p>
48
+ * Feature used to be one of {@link tools.jackson.databind.SerializationFeature}s
49
+ * in Jackson 2.x but was moved here in 3.0.
50
+ *<p>
51
+ * Feature is enabled by default as of Jackson 3.0 (in 2.x it was disabled).
52
+ */
53
+ WRITE_ENUMS_USING_TO_STRING (true ),
54
+
55
+ /**
56
+ * Feature that determines whether Java Enum values are serialized
57
+ * as numbers (true), or textual values (false). If textual values are
58
+ * used, other settings are also considered.
59
+ * If this feature is enabled,
60
+ * return value of <code>Enum.ordinal()</code>
61
+ * (an integer) will be used as the serialization.
62
+ *<p>
63
+ * Note that this feature has precedence over {@link #WRITE_ENUMS_USING_TO_STRING},
64
+ * which is only considered if this feature is set to false.
65
+ *<p>
66
+ * Note that since 2.10, this does NOT apply to {@link Enum}s written as
67
+ * keys of {@link java.util.Map} values, which has separate setting,
68
+ * {@link #WRITE_ENUM_KEYS_USING_INDEX}.
69
+ *<p>
70
+ * Feature used to be one of {@link tools.jackson.databind.SerializationFeature}s
71
+ * in Jackson 2.x but was moved here in 3.0.
72
+ *<p>
73
+ * Feature is disabled by default.
74
+ */
75
+ WRITE_ENUMS_USING_INDEX (false ),
76
+
77
+ /**
78
+ * Feature that determines whether {link Enum}s
79
+ * used as {@link java.util.Map} keys are serialized
80
+ * as using {@link Enum#ordinal()} or not.
81
+ * Similar to {@link #WRITE_ENUMS_USING_INDEX} used when writing
82
+ * {@link Enum}s as regular values.
83
+ *<p>
84
+ * NOTE: counterpart for this settings is
85
+ * {@link EnumFeature#READ_ENUM_KEYS_USING_INDEX}.
86
+ *<p>
87
+ * Feature used to be one of {@link tools.jackson.databind.SerializationFeature}s
88
+ * in Jackson 2.x but was moved here in 3.0.
89
+ *<p>
90
+ * Feature is disabled by default.
91
+ */
92
+ WRITE_ENUM_KEYS_USING_INDEX (false ),
93
+ ;
38
94
39
95
private final static int FEATURE_INDEX = DatatypeFeatures .FEATURE_INDEX_ENUM ;
40
96
0 commit comments