File tree 4 files changed +49
-2
lines changed
main/java/com/fasterxml/jackson/databind
test/java/com/fasterxml/jackson/databind
4 files changed +49
-2
lines changed Original file line number Diff line number Diff line change @@ -961,6 +961,13 @@ public boolean isEnabled(JsonParser.Feature f) {
961
961
return _config .isEnabled (f , _parserFactory );
962
962
}
963
963
964
+ /**
965
+ * @since 2.11
966
+ */
967
+ public boolean isEnabled (StreamReadFeature f ) {
968
+ return _config .isEnabled (f .mappedFeature (), _parserFactory );
969
+ }
970
+
964
971
/**
965
972
* @since 2.2
966
973
*/
Original file line number Diff line number Diff line change @@ -349,6 +349,26 @@ public ObjectWriter withoutFeatures(JsonGenerator.Feature... features) {
349
349
return _new (this , _config .withoutFeatures (features ));
350
350
}
351
351
352
+ /*
353
+ /**********************************************************
354
+ /* Life-cycle, fluent factories for StreamWriteFeature (2.11)
355
+ /**********************************************************
356
+ */
357
+
358
+ /**
359
+ * @since 2.11
360
+ */
361
+ public ObjectWriter with (StreamWriteFeature feature ) {
362
+ return _new (this , _config .with (feature .mappedFeature ()));
363
+ }
364
+
365
+ /**
366
+ * @since 2.11
367
+ */
368
+ public ObjectWriter without (StreamWriteFeature feature ) {
369
+ return _new (this , _config .without (feature .mappedFeature ()));
370
+ }
371
+
352
372
/*
353
373
/**********************************************************
354
374
/* Life-cycle, fluent factories for FormatFeature (2.7)
@@ -908,7 +928,14 @@ public boolean isEnabled(JsonParser.Feature f) {
908
928
public boolean isEnabled (JsonGenerator .Feature f ) {
909
929
return _generatorFactory .isEnabled (f );
910
930
}
911
-
931
+
932
+ /**
933
+ * @since 2.11
934
+ */
935
+ public boolean isEnabled (StreamWriteFeature f ) {
936
+ return _generatorFactory .isEnabled (f );
937
+ }
938
+
912
939
/**
913
940
* @since 2.2
914
941
*/
Original file line number Diff line number Diff line change @@ -112,6 +112,14 @@ public void testFeatureSettings() throws Exception
112
112
113
113
// and another one
114
114
assertSame (r , r .with (r .getConfig ()));
115
+
116
+ // and with StreamReadFeatures
117
+ r = MAPPER .reader ();
118
+ assertFalse (r .isEnabled (StreamReadFeature .IGNORE_UNDEFINED ));
119
+ ObjectReader r2 = r .with (StreamReadFeature .IGNORE_UNDEFINED );
120
+ assertTrue (r2 .isEnabled (StreamReadFeature .IGNORE_UNDEFINED ));
121
+ ObjectReader r3 = r2 .without (StreamReadFeature .IGNORE_UNDEFINED );
122
+ assertFalse (r3 .isEnabled (StreamReadFeature .IGNORE_UNDEFINED ));
115
123
}
116
124
117
125
public void testFeatureSettingsDeprecated () throws Exception
Original file line number Diff line number Diff line change @@ -234,6 +234,8 @@ public void testFeatureSettings() throws Exception
234
234
ObjectWriter w = MAPPER .writer ();
235
235
assertFalse (w .isEnabled (MapperFeature .ACCEPT_CASE_INSENSITIVE_PROPERTIES ));
236
236
assertFalse (w .isEnabled (JsonGenerator .Feature .STRICT_DUPLICATE_DETECTION ));
237
+ assertFalse (w .isEnabled (StreamWriteFeature .STRICT_DUPLICATE_DETECTION ));
238
+
237
239
ObjectWriter newW = w .with (SerializationFeature .FAIL_ON_UNWRAPPED_TYPE_IDENTIFIERS ,
238
240
SerializationFeature .INDENT_OUTPUT );
239
241
assertNotSame (w , newW );
@@ -267,8 +269,11 @@ public void testGeneratorFeatures() throws Exception
267
269
assertTrue (w .isEnabled (JsonGenerator .Feature .AUTO_CLOSE_TARGET ));
268
270
assertNotSame (w , w .without (JsonGenerator .Feature .AUTO_CLOSE_TARGET ));
269
271
assertNotSame (w , w .withoutFeatures (JsonGenerator .Feature .AUTO_CLOSE_TARGET ));
272
+
273
+ assertFalse (w .isEnabled (StreamWriteFeature .STRICT_DUPLICATE_DETECTION ));
274
+ assertNotSame (w , w .with (StreamWriteFeature .STRICT_DUPLICATE_DETECTION ));
270
275
}
271
-
276
+
272
277
/*
273
278
/**********************************************************
274
279
/* Test methods, failures
You can’t perform that action at this time.
0 commit comments