Skip to content

Commit 39b9deb

Browse files
committed
Merge branch '2.13'
2 parents cad0206 + 842597e commit 39b9deb

File tree

8 files changed

+36
-31
lines changed

8 files changed

+36
-31
lines changed

release-notes/VERSION-2.x

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Project: jackson-databind
1515
#3002: Add `DeserializationContext.readTreeAsValue()` methods for more convenient
1616
conversions for deserializers to use
1717
#3011: Clean up support of typed "unmodifiable", "singleton" Maps/Sets/Collections
18+
#3033: Extend internal bitfield of `MapperFeature` to be `long`
1819
#3035: Add `removeMixIn()` method in `MapperBuilder`
1920
#3036: Backport `MapperBuilder` lambda-taking methods: `withConfigOverride()`,
2021
`withCoercionConfig()`, `withCoercionConfigDefaults()`

src/main/java/com/fasterxml/jackson/databind/DeserializationConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public final class DeserializationConfig
8989
/**
9090
* @since 3.0
9191
*/
92-
public DeserializationConfig(MapperBuilder<?,?> b, int mapperFeatures,
92+
public DeserializationConfig(MapperBuilder<?,?> b, long mapperFeatures,
9393
int deserFeatures, int streamReadFeatures, int formatReadFeatures,
9494
ConfigOverrides configOverrides, CoercionConfigs coercionConfigs,
9595
TypeFactory tf, ClassIntrospector classIntr, MixInHandler mixins, SubtypeResolver str,

src/main/java/com/fasterxml/jackson/databind/MapperFeature.java

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
11
package com.fasterxml.jackson.databind;
22

33
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
4-
import com.fasterxml.jackson.databind.cfg.ConfigFeature;
54

65
/**
76
* Enumeration that defines simple on/off features to set
87
* for {@link ObjectMapper}, and accessible (but not changeable)
98
* via {@link ObjectReader} and {@link ObjectWriter} (as well as
109
* through various convenience methods through context objects).
11-
*<p>
12-
* Note that in addition to being only mutable via {@link ObjectMapper},
13-
* changes only take effect when done <b>before any serialization or
14-
* deserialization</b> calls -- that is, caller must follow
15-
* "configure-then-use" pattern.
1610
*/
17-
public enum MapperFeature implements ConfigFeature
11+
public enum MapperFeature
1812
{
1913
/*
2014
/**********************************************************************
@@ -285,8 +279,6 @@ public enum MapperFeature implements ConfigFeature
285279
* entries are not considered Bean/POJO properties.
286280
*<p>
287281
* Feature is enabled by default.
288-
*
289-
* @since 2.12
290282
*/
291283
SORT_CREATOR_PROPERTIES_FIRST(true),
292284

@@ -403,19 +395,30 @@ public enum MapperFeature implements ConfigFeature
403395
;
404396

405397
private final boolean _defaultState;
406-
private final int _mask;
407-
398+
private final long _mask;
399+
400+
public static long collectLongDefaults() {
401+
int flags = 0;
402+
for (MapperFeature value : MapperFeature.values()) {
403+
if (value.enabledByDefault()) {
404+
flags |= value.getLongMask();
405+
}
406+
}
407+
return flags;
408+
}
409+
408410
private MapperFeature(boolean defaultState) {
409411
_defaultState = defaultState;
410-
_mask = (1 << ordinal());
412+
_mask = (1L << ordinal());
411413
}
412414

413-
@Override
414415
public boolean enabledByDefault() { return _defaultState; }
415416

416-
@Override
417-
public int getMask() { return _mask; }
417+
public long getLongMask() {
418+
return _mask;
419+
}
418420

419-
@Override
420-
public boolean enabledIn(int flags) { return (flags & _mask) != 0; }
421+
public boolean enabledIn(long flags) {
422+
return (flags & _mask) != 0;
423+
}
421424
}

src/main/java/com/fasterxml/jackson/databind/SerializationConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public final class SerializationConfig
8080
* @since 3.0
8181
*/
8282
public SerializationConfig(MapperBuilder<?,?> b,
83-
int mapperFeatures, int serFeatures, int streamWriteFeatures, int formatWriteFeatures,
83+
long mapperFeatures, int serFeatures, int streamWriteFeatures, int formatWriteFeatures,
8484
ConfigOverrides configOverrides,
8585
TypeFactory tf, ClassIntrospector classIntr, MixInHandler mixins, SubtypeResolver str,
8686
ContextAttributes defaultAttrs, RootNameLookup rootNames,

src/main/java/com/fasterxml/jackson/databind/cfg/MapperBuilder.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
public abstract class MapperBuilder<M extends ObjectMapper,
4242
B extends MapperBuilder<M,B>>
4343
{
44-
protected final static int DEFAULT_MAPPER_FEATURES = ConfigFeature.collectFeatureDefaults(MapperFeature.class);
44+
protected final static long DEFAULT_MAPPER_FEATURES = MapperFeature.collectLongDefaults();
4545
protected final static int DEFAULT_SER_FEATURES = ConfigFeature.collectFeatureDefaults(SerializationFeature.class);
4646
protected final static int DEFAULT_DESER_FEATURES = ConfigFeature.collectFeatureDefaults(DeserializationFeature.class);
4747

@@ -202,7 +202,7 @@ public abstract class MapperBuilder<M extends ObjectMapper,
202202
/**
203203
* Set of shared mapper features enabled.
204204
*/
205-
protected int _mapperFeatures;
205+
protected long _mapperFeatures;
206206

207207
/**
208208
* Set of {@link SerializationFeature}s enabled.
@@ -276,7 +276,7 @@ protected MapperBuilder(TokenStreamFactory streamFactory)
276276
_mapperFeatures = DEFAULT_MAPPER_FEATURES;
277277
// Some overrides we may need based on format
278278
if (streamFactory.requiresPropertyOrdering()) {
279-
_mapperFeatures |= MapperFeature.SORT_PROPERTIES_ALPHABETICALLY.getMask();
279+
_mapperFeatures |= MapperFeature.SORT_PROPERTIES_ALPHABETICALLY.getLongMask();
280280
}
281281
_deserFeatures = DEFAULT_DESER_FEATURES;
282282
_serFeatures = DEFAULT_SER_FEATURES;
@@ -700,24 +700,24 @@ public LinkedNode<DeserializationProblemHandler> deserializationProblemHandlers(
700700

701701
public B enable(MapperFeature... features) {
702702
for (MapperFeature f : features) {
703-
_mapperFeatures |= f.getMask();
703+
_mapperFeatures |= f.getLongMask();
704704
}
705705
return _this();
706706
}
707707

708708
public B disable(MapperFeature... features) {
709709
for (MapperFeature f : features) {
710-
_mapperFeatures &= ~f.getMask();
710+
_mapperFeatures &= ~f.getLongMask();
711711
}
712712
return _this();
713713
}
714714

715715
public B configure(MapperFeature feature, boolean state)
716716
{
717717
if (state) {
718-
_mapperFeatures |= feature.getMask();
718+
_mapperFeatures |= feature.getLongMask();
719719
} else {
720-
_mapperFeatures &= ~feature.getMask();
720+
_mapperFeatures &= ~feature.getLongMask();
721721
}
722722
return _this();
723723
}

src/main/java/com/fasterxml/jackson/databind/cfg/MapperBuilderState.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ public abstract class MapperBuilderState
5151
/**********************************************************************
5252
*/
5353

54-
protected final int _mapperFeatures, _serFeatures, _deserFeatures;
54+
protected final long _mapperFeatures;
55+
protected final int _serFeatures, _deserFeatures;
5556
protected final int _streamReadFeatures, _streamWriteFeatures;
5657
protected final int _formatReadFeatures, _formatWriteFeatures;
5758

src/main/java/com/fasterxml/jackson/databind/cfg/MapperConfig.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public abstract class MapperConfig<T extends MapperConfig<T>>
4747
/**
4848
* Set of shared mapper features enabled.
4949
*/
50-
protected final int _mapperFeatures;
50+
protected final long _mapperFeatures;
5151

5252
/**
5353
* Immutable container object for simple configuration settings.
@@ -60,7 +60,7 @@ public abstract class MapperConfig<T extends MapperConfig<T>>
6060
/**********************************************************************
6161
*/
6262

63-
protected MapperConfig(BaseSettings base, int mapperFeatures)
63+
protected MapperConfig(BaseSettings base, long mapperFeatures)
6464
{
6565
_base = base;
6666
_mapperFeatures = mapperFeatures;
@@ -89,7 +89,7 @@ protected MapperConfig(MapperConfig<T> src)
8989
* serialization, deserialization)
9090
*/
9191
public final boolean isEnabled(MapperFeature f) {
92-
return (_mapperFeatures & f.getMask()) != 0;
92+
return (_mapperFeatures & f.getLongMask()) != 0;
9393
}
9494

9595
/**

src/main/java/com/fasterxml/jackson/databind/cfg/MapperConfigBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public abstract class MapperConfigBase<CFG extends ConfigFeature,
110110
* Constructor used when creating a new instance (compared to
111111
* that of creating fluent copies)
112112
*/
113-
protected MapperConfigBase(MapperBuilder<?,?> b, int mapperFeatures,
113+
protected MapperConfigBase(MapperBuilder<?,?> b, long mapperFeatures,
114114
TypeFactory tf, ClassIntrospector classIntr, MixInHandler mixins, SubtypeResolver str,
115115
ConfigOverrides configOverrides, ContextAttributes defaultAttrs,
116116
RootNameLookup rootNames)

0 commit comments

Comments
 (0)