Skip to content

Commit 7736252

Browse files
committed
Renaming of feature added in #137
1 parent 6ab3060 commit 7736252

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

cbor/src/main/java/com/fasterxml/jackson/dataformat/cbor/CBORParser.java

+14-13
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,23 @@ public enum Feature implements FormatFeature
4848
DECODE_USING_STANDARD_NEGATIVE_BIGINT_ENCODING(false),
4949

5050
/**
51-
* Feature that determines how an {@code undefined} value ({@code 0xF7}) is decoded.
51+
* Feature that determines how an {@code undefined} value ({@code 0xF7}) is exposed
52+
* by parser.
5253
* <p>
53-
* When enabled, the parser returns {@link JsonToken#VALUE_EMBEDDED_OBJECT} with a
54-
* value of {@code null}, allowing the caller to distinguish {@code undefined} from actual
54+
* When enabled, the parser returns {@link JsonToken#VALUE_EMBEDDED_OBJECT} with
55+
* a value of {@code null}, allowing the caller to distinguish {@code undefined} from actual
5556
* {@link JsonToken#VALUE_NULL}.
56-
* When disabled (default, for backwards compatibility), {@code undefined} value is
57-
* reported as {@link JsonToken#VALUE_NULL}, maintaining legacy behavior
58-
* in use up to Jackson 2.19.
57+
* When disabled {@code undefined} value is reported as {@link JsonToken#VALUE_NULL}.
58+
*<p>
59+
* The default value is {@code false} for backwards compatibility (with versions prior to 2.20).
5960
*
6061
* @since 2.20
6162
*/
62-
HANDLE_UNDEFINED_AS_EMBEDDED_OBJECT(false)
63+
READ_UNDEFINED_AS_EMBEDDED_OBJECT(false)
6364
;
6465

65-
final boolean _defaultState;
66-
final int _mask;
66+
private final boolean _defaultState;
67+
private final int _mask;
6768

6869
/**
6970
* Method that calculates bit set (flags) of all features that
@@ -206,7 +207,7 @@ public int getFirstTag() {
206207
* @since 2.20
207208
*/
208209
protected int _formatFeatures;
209-
210+
210211
/**
211212
* Codec used for data binding when (if) requested.
212213
*/
@@ -1933,7 +1934,7 @@ private final byte[] _getBinaryFromString(Base64Variant variant) throws IOExcept
19331934
* Checking whether the current token represents an `undefined` value (0xF7).
19341935
* <p>
19351936
* This method allows distinguishing between real {@code null} and `undefined`,
1936-
* even if {@link CBORParser.Feature#HANDLE_UNDEFINED_AS_EMBEDDED_OBJECT} is disabled
1937+
* even if {@link CBORParser.Feature#READ_UNDEFINED_AS_EMBEDDED_OBJECT} is disabled
19371938
* and the token is reported as {@link JsonToken#VALUE_NULL}.
19381939
*
19391940
* @return {@code true} if current token is an `undefined`, {@code false} otherwise
@@ -3694,14 +3695,14 @@ private final static long _long(int i1, int i2)
36943695
* as {@link JsonToken#VALUE_NULL} by default.
36953696
* <p>
36963697
*
3697-
* since 2.20 If {@link CBORParser.Feature#HANDLE_UNDEFINED_AS_EMBEDDED_OBJECT} is enabled,
3698+
* since 2.20 If {@link CBORParser.Feature#READ_UNDEFINED_AS_EMBEDDED_OBJECT} is enabled,
36983699
* the value will instead be decoded as {@link JsonToken#VALUE_EMBEDDED_OBJECT}
36993700
* with an embedded value of {@code null}.
37003701
*
37013702
* @since 2.10
37023703
*/
37033704
protected JsonToken _decodeUndefinedValue() {
3704-
if (Feature.HANDLE_UNDEFINED_AS_EMBEDDED_OBJECT.enabledIn(_formatFeatures)) {
3705+
if (Feature.READ_UNDEFINED_AS_EMBEDDED_OBJECT.enabledIn(_formatFeatures)) {
37053706
_binaryValue = null; // should be clear but just in case
37063707
return JsonToken.VALUE_EMBEDDED_OBJECT;
37073708
}

cbor/src/test/java/com/fasterxml/jackson/dataformat/cbor/parse/UndefinedValueTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public void testUndefinedLiteralStreaming() throws Exception
3232
@Test
3333
public void testUndefinedLiteralAsEmbeddedObject() throws Exception {
3434
CBORFactory f = CBORFactory.builder()
35-
.enable(CBORParser.Feature.HANDLE_UNDEFINED_AS_EMBEDDED_OBJECT)
35+
.enable(CBORParser.Feature.READ_UNDEFINED_AS_EMBEDDED_OBJECT)
3636
.build();
3737
CBORParser p = cborParser(f, new byte[] { BYTE_UNDEFINED });
3838

@@ -62,7 +62,7 @@ public void testUndefinedInArray() throws Exception
6262
@Test
6363
public void testUndefinedInArrayAsEmbeddedObject() throws Exception {
6464
CBORFactory f = CBORFactory.builder()
65-
.enable(CBORParser.Feature.HANDLE_UNDEFINED_AS_EMBEDDED_OBJECT)
65+
.enable(CBORParser.Feature.READ_UNDEFINED_AS_EMBEDDED_OBJECT)
6666
.build();
6767

6868
ByteArrayOutputStream out = new ByteArrayOutputStream();
@@ -108,7 +108,7 @@ public void testUndefinedInObject() throws Exception
108108
@Test
109109
public void testUndefinedInObjectAsEmbeddedObject() throws Exception {
110110
CBORFactory f = CBORFactory.builder()
111-
.enable(CBORParser.Feature.HANDLE_UNDEFINED_AS_EMBEDDED_OBJECT)
111+
.enable(CBORParser.Feature.READ_UNDEFINED_AS_EMBEDDED_OBJECT)
112112
.build();
113113

114114
ByteArrayOutputStream out = new ByteArrayOutputStream();

release-notes/VERSION-2.x

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ Active maintainers:
1818

1919
#137: (cbor) Allow exposing CBOR "undefined" value as `JsonToken.VALUE_EMBEDDED_OBJECT`;
2020
with embedded value of `null`
21-
(implementation contributed by Fawzi E)
22-
21+
(implementation contributed by Fawzi E)
2322
#431: (cbor) Negative `BigInteger` values not encoded/decoded correctly
2423
(reported by Brian G)
2524
(fix contributed by Fawzi E)

0 commit comments

Comments
 (0)