Skip to content

Commit ecbc043

Browse files
committed
And then add Smile impl
1 parent 2848abd commit ecbc043

File tree

5 files changed

+33
-9
lines changed

5 files changed

+33
-9
lines changed

release-notes/CREDITS

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ Fawzi Essam (@iifawzi)
1515
* Contributed #582: Change defaults for `CBORReadFeature.DECODE_USING_STANDARD_NEGATIVE_BIGINT_ENCODING`
1616
and `CBORWriteFeature.ENCODE_USING_STANDARD_NEGATIVE_BIGINT_ENCODING` to `true` (enabled)
1717
(3.0.0)
18-
* Contribited #591: Change `CBOR` Features defaults for 3.0
18+
* Contributed #591: Change `CBOR` Features defaults for 3.0
1919
(3.0.0)
2020

2121
Andy Wilkinson (@wilkinsona)
2222

23-
* Requested #619: (avro, cbor) Add `isEnabled()` methods for format-specific features (like
24-
`CBORReadFeature` and `CBORWriteFeature`) to mappers
23+
* Requested #619: (avro, cbor, ion, smile) Add `isEnabled()` methods for format-specific features
24+
(like `CBORReadFeature` and `CBORWriteFeature`) to mappers
2525
(3.1.0)

release-notes/VERSION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ implementations)
1616

1717
3.1.0 (not yet released)
1818

19-
#619: (avro, cbor, ion) Add `isEnabled()` methods for format-specific features (like
20-
`CBORReadFeature` and `CBORWriteFeature`) to mappers
19+
#619: (avro, cbor, ion, smile) Add `isEnabled()` methods for format-specific features
20+
(like `CBORReadFeature` and `CBORWriteFeature`) to mappers
2121
(requested by Andy W)
2222

2323
3.0.1 (21-Oct-2025)

smile/src/main/java/tools/jackson/dataformat/smile/SmileMapper.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,20 @@ public SmileFactory tokenStreamFactory() {
173173
return (SmileFactory) _streamFactory;
174174
}
175175

176+
/*
177+
/**********************************************************************
178+
/* Format-specific
179+
/**********************************************************************
180+
*/
181+
182+
public boolean isEnabled(SmileReadFeature f) {
183+
return _deserializationConfig.hasFormatFeature(f);
184+
}
185+
186+
public boolean isEnabled(SmileWriteFeature f) {
187+
return _serializationConfig.hasFormatFeature(f);
188+
}
189+
176190
/*
177191
/**********************************************************************
178192
/* Helper class(es)

smile/src/main/java/tools/jackson/dataformat/smile/SmileReadFeature.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ public enum SmileReadFeature implements FormatFeature
1414
* or optional. If enabled, it means that only input that starts with the header
1515
* is accepted as valid; if disabled, header is optional. In latter case,
1616
* settings for content are assumed to be defaults.
17+
*<p>
18+
* Feature is enabled by default.
1719
*/
1820
REQUIRE_HEADER(true)
1921
;

smile/src/test/java/tools/jackson/dataformat/smile/mapper/MapperFeaturesTest.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
import org.junit.jupiter.api.Test;
44

55
import tools.jackson.databind.*;
6-
import tools.jackson.dataformat.smile.BaseTestForSmile;
7-
import tools.jackson.dataformat.smile.SmileFactory;
8-
import tools.jackson.dataformat.smile.SmileMapper;
6+
7+
import tools.jackson.dataformat.smile.*;
98

109
import static org.junit.jupiter.api.Assertions.assertEquals;
10+
import static org.junit.jupiter.api.Assertions.assertTrue;
1111

1212
public class MapperFeaturesTest extends BaseTestForSmile
1313
{
14-
static class Bean {
14+
public static class Bean {
1515
public int value;
1616
}
1717

@@ -35,4 +35,12 @@ public void testIndent() throws Exception
3535
Bean result = mapper.readValue(smile, 0, smile.length, Bean.class);
3636
assertEquals(42, result.value);
3737
}
38+
39+
// [dataformats-binary#619]
40+
@Test
41+
void testFormatFeatureDefaults() {
42+
SmileMapper mapper = SmileMapper.shared();
43+
assertTrue(mapper.isEnabled(SmileReadFeature.REQUIRE_HEADER));
44+
assertTrue(mapper.isEnabled(SmileWriteFeature.WRITE_HEADER));
45+
}
3846
}

0 commit comments

Comments
 (0)