Skip to content

Commit 01fa66b

Browse files
authored
Fix #780: add XmlMapper.isEnabled() methods (#781)
1 parent 5979dc5 commit 01fa66b

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

release-notes/VERSION

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ Version: 3.x (for earlier see VERSION-2.x)
55
=== Releases ===
66
------------------------------------------------------------------------
77

8+
3.1.0 (not yet released)
9+
10+
#780: Add `isEnabled()` methods for format-specific features to mappers
11+
812
3.0.1 (21-Oct-2025)
913

1014
No changes since 3.0.0

src/main/java/tools/jackson/dataformat/xml/XmlMapper.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,21 @@ public XmlFactory tokenStreamFactory() {
458458
return (XmlFactory) _streamFactory;
459459
}
460460

461+
/*
462+
/**********************************************************************
463+
/* Format-specific
464+
/**********************************************************************
465+
*/
466+
467+
public boolean isEnabled(XmlReadFeature f) {
468+
return _deserializationConfig.hasFormatFeature(f);
469+
}
470+
471+
public boolean isEnabled(XmlWriteFeature f) {
472+
return _serializationConfig.hasFormatFeature(f);
473+
}
474+
475+
461476
/*
462477
/**********************************************************************
463478
/* XML-specific access

src/test/java/tools/jackson/dataformat/xml/FeatureDefaultsTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import tools.jackson.databind.ObjectWriter;
77

88
import static org.junit.jupiter.api.Assertions.assertNotSame;
9+
import static org.junit.jupiter.api.Assertions.assertTrue;
910

1011
public class FeatureDefaultsTest extends XmlTestUtil
1112
{
@@ -24,4 +25,13 @@ public void testSerDefaults() throws Exception
2425
ObjectWriter w = MAPPER.writer();
2526
assertNotSame(w, w.with(XmlWriteFeature.WRITE_XML_1_1));
2627
}
28+
29+
// [dataformat-xml#780]
30+
@Test
31+
void testFeaturesViaMapper() {
32+
XmlMapper mapper = XmlMapper.shared();
33+
assertTrue(mapper.isEnabled(XmlReadFeature.AUTO_DETECT_XSI_TYPE));
34+
assertTrue(mapper.isEnabled(XmlWriteFeature.AUTO_DETECT_XSI_TYPE));
35+
36+
}
2737
}

0 commit comments

Comments
 (0)