@@ -92,15 +92,31 @@ public enum MyEnum {
92
92
String namespace () default "" ;
93
93
94
94
/**
95
- * Property that indicates whether a value (which may be explicit
96
- * null) is expected for property during deserialization or not.
97
- * If expected, <code>BeanDeserialized</code> should indicate
95
+ * Property similar to {@link #isRequired}, but one that only
96
+ * allows two values ({@code true} and {@code false}), defaulting
97
+ * to {@code false}.
98
+ *<p>
99
+ * NOTE: as of Jackson 2.19, there is newer property, {@link #isRequired()},
100
+ * to be used instead.
101
+ *
102
+ * @since 2.0
103
+ */
104
+ boolean required () default false ;
105
+
106
+ /**
107
+ * Property that MAY indicate whether a value (which may be explicit
108
+ * null) is required for a property during deserialization or not.
109
+ * If required ({code OptBoolean.TRUE}), {@code Deserializer} should indicate
98
110
* this as a validity problem (usually by throwing an exception,
99
111
* but this may be sent via problem handlers that can try to
100
- * rectify the problem, for example, by supplying a default
101
- * value).
112
+ * rectify the problem, for example, by supplying a default value) if no
113
+ * value is present in incoming content. If not required ({code OptBoolean.FALSE}),
114
+ * no checking is to be done.
115
+ * If not specified ({code OptBoolean.DEFAULT}) checking depends on higher
116
+ * level settings (some modules may specify default "required-ness" for certain
117
+ * kinds of properties).
102
118
*<p>
103
- * Note that as of 2.6 , this property is only used for Creator
119
+ * Note that as of 2.19 , this property is only used for Creator
104
120
* Properties, to ensure existence of property value in JSON:
105
121
* for other properties (ones injected using a setter or mutable
106
122
* field), no validation is performed. Support for those cases
@@ -116,11 +132,18 @@ public enum MyEnum {
116
132
* this property should be set to {@code false}. This is important because
117
133
* validation of {@code required} properties occurs before the application of
118
134
* secondary sources.
135
+ *<p>
136
+ * Default value ({@link OptBoolean#DEFAULT}) means that "required-ness"
137
+ * is not specified by this annotation -- it is up to more general settings
138
+ * (per-class, global) to determine whether the property is required or not.
139
+ *<p>
140
+ * NOTE: as of Jackson 2.19, the older property, {@link #required()},
141
+ * is considered deprecated and should not be used.
119
142
*
120
- * @since 2.0
143
+ * @since 2.19
121
144
*/
122
- boolean required () default false ;
123
-
145
+ OptBoolean isRequired () default OptBoolean . DEFAULT ;
146
+
124
147
/**
125
148
* Property that indicates numerical index of this property (relative
126
149
* to other properties specified for the Object). This index
0 commit comments