12
12
import com .fasterxml .jackson .databind .MapperFeature ;
13
13
import com .fasterxml .jackson .databind .PropertyNamingStrategy ;
14
14
import com .fasterxml .jackson .databind .introspect .ClassIntrospector ;
15
+ import com .fasterxml .jackson .databind .introspect .ClassIntrospector .MixInResolver ;
16
+ import com .fasterxml .jackson .databind .introspect .SimpleMixInResolver ;
15
17
import com .fasterxml .jackson .databind .introspect .VisibilityChecker ;
16
18
import com .fasterxml .jackson .databind .jsontype .SubtypeResolver ;
17
19
import com .fasterxml .jackson .databind .jsontype .TypeResolverBuilder ;
18
- import com .fasterxml .jackson .databind .type .ClassKey ;
19
20
import com .fasterxml .jackson .databind .type .TypeFactory ;
20
21
22
+ @ SuppressWarnings ("serial" )
21
23
public abstract class MapperConfigBase <CFG extends ConfigFeature ,
22
24
T extends MapperConfigBase <CFG ,T >>
23
25
extends MapperConfig <T >
24
26
implements java .io .Serializable
25
27
{
26
- private static final long serialVersionUID = 6062961959359172474L ;
27
-
28
28
private final static int DEFAULT_MAPPER_FEATURES = collectFeatureDefaults (MapperFeature .class );
29
29
30
30
/*
@@ -36,8 +36,10 @@ public abstract class MapperConfigBase<CFG extends ConfigFeature,
36
36
/**
37
37
* Mix-in annotation mappings to use, if any: immutable,
38
38
* can not be changed once defined.
39
+ *
40
+ * @since 2.6
39
41
*/
40
- protected final Map < ClassKey , Class <?>> _mixInAnnotations ;
42
+ protected final SimpleMixInResolver _mixIns ;
41
43
42
44
/**
43
45
* Registered concrete subtypes that can be used instead of (or
@@ -79,10 +81,10 @@ public abstract class MapperConfigBase<CFG extends ConfigFeature,
79
81
* that of creating fluent copies)
80
82
*/
81
83
protected MapperConfigBase (BaseSettings base ,
82
- SubtypeResolver str , Map < ClassKey , Class <?>> mixins )
84
+ SubtypeResolver str , SimpleMixInResolver mixins )
83
85
{
84
86
super (base , DEFAULT_MAPPER_FEATURES );
85
- _mixInAnnotations = mixins ;
87
+ _mixIns = mixins ;
86
88
_subtypeResolver = str ;
87
89
_rootName = null ;
88
90
_view = null ;
@@ -97,7 +99,7 @@ protected MapperConfigBase(BaseSettings base,
97
99
protected MapperConfigBase (MapperConfigBase <CFG ,T > src )
98
100
{
99
101
super (src );
100
- _mixInAnnotations = src ._mixInAnnotations ;
102
+ _mixIns = src ._mixIns ;
101
103
_subtypeResolver = src ._subtypeResolver ;
102
104
_rootName = src ._rootName ;
103
105
_view = src ._view ;
@@ -107,7 +109,7 @@ protected MapperConfigBase(MapperConfigBase<CFG,T> src)
107
109
protected MapperConfigBase (MapperConfigBase <CFG ,T > src , BaseSettings base )
108
110
{
109
111
super (base , src ._mapperFeatures );
110
- _mixInAnnotations = src ._mixInAnnotations ;
112
+ _mixIns = src ._mixIns ;
111
113
_subtypeResolver = src ._subtypeResolver ;
112
114
_rootName = src ._rootName ;
113
115
_view = src ._view ;
@@ -117,7 +119,7 @@ protected MapperConfigBase(MapperConfigBase<CFG,T> src, BaseSettings base)
117
119
protected MapperConfigBase (MapperConfigBase <CFG ,T > src , int mapperFeatures )
118
120
{
119
121
super (src ._base , mapperFeatures );
120
- _mixInAnnotations = src ._mixInAnnotations ;
122
+ _mixIns = src ._mixIns ;
121
123
_subtypeResolver = src ._subtypeResolver ;
122
124
_rootName = src ._rootName ;
123
125
_view = src ._view ;
@@ -126,7 +128,7 @@ protected MapperConfigBase(MapperConfigBase<CFG,T> src, int mapperFeatures)
126
128
127
129
protected MapperConfigBase (MapperConfigBase <CFG ,T > src , SubtypeResolver str ) {
128
130
super (src );
129
- _mixInAnnotations = src ._mixInAnnotations ;
131
+ _mixIns = src ._mixIns ;
130
132
_subtypeResolver = str ;
131
133
_rootName = src ._rootName ;
132
134
_view = src ._view ;
@@ -135,7 +137,7 @@ protected MapperConfigBase(MapperConfigBase<CFG,T> src, SubtypeResolver str) {
135
137
136
138
protected MapperConfigBase (MapperConfigBase <CFG ,T > src , String rootName ) {
137
139
super (src );
138
- _mixInAnnotations = src ._mixInAnnotations ;
140
+ _mixIns = src ._mixIns ;
139
141
_subtypeResolver = src ._subtypeResolver ;
140
142
_rootName = rootName ;
141
143
_view = src ._view ;
@@ -145,7 +147,7 @@ protected MapperConfigBase(MapperConfigBase<CFG,T> src, String rootName) {
145
147
protected MapperConfigBase (MapperConfigBase <CFG ,T > src , Class <?> view )
146
148
{
147
149
super (src );
148
- _mixInAnnotations = src ._mixInAnnotations ;
150
+ _mixIns = src ._mixIns ;
149
151
_subtypeResolver = src ._subtypeResolver ;
150
152
_rootName = src ._rootName ;
151
153
_view = view ;
@@ -155,10 +157,10 @@ protected MapperConfigBase(MapperConfigBase<CFG,T> src, Class<?> view)
155
157
/**
156
158
* @since 2.1
157
159
*/
158
- protected MapperConfigBase (MapperConfigBase <CFG ,T > src , Map < ClassKey , Class <?>> mixins )
160
+ protected MapperConfigBase (MapperConfigBase <CFG ,T > src , SimpleMixInResolver mixins )
159
161
{
160
162
super (src );
161
- _mixInAnnotations = mixins ;
163
+ _mixIns = mixins ;
162
164
_subtypeResolver = src ._subtypeResolver ;
163
165
_rootName = src ._rootName ;
164
166
_view = src ._view ;
@@ -171,7 +173,7 @@ protected MapperConfigBase(MapperConfigBase<CFG,T> src, Map<ClassKey,Class<?>> m
171
173
protected MapperConfigBase (MapperConfigBase <CFG ,T > src , ContextAttributes attr )
172
174
{
173
175
super (src );
174
- _mixInAnnotations = src ._mixInAnnotations ;
176
+ _mixIns = src ._mixIns ;
175
177
_subtypeResolver = src ._subtypeResolver ;
176
178
_rootName = src ._rootName ;
177
179
_view = src ._view ;
@@ -401,10 +403,20 @@ public final ContextAttributes getAttributes() {
401
403
*/
402
404
@ Override
403
405
public final Class <?> findMixInClassFor (Class <?> cls ) {
404
- return ( _mixInAnnotations == null ) ? null : _mixInAnnotations . get ( new ClassKey ( cls ) );
406
+ return _mixIns . findMixInClassFor ( cls );
405
407
}
406
408
409
+ // Not really relevant here (should not get called)
410
+ @ Override
411
+ public MixInResolver copy () {
412
+ throw new UnsupportedOperationException ();
413
+ }
414
+
415
+ /**
416
+ * Test-only method -- does not reflect possibly open-ended set that external
417
+ * mix-in resolver might provide.
418
+ */
407
419
public final int mixInCount () {
408
- return ( _mixInAnnotations == null ) ? 0 : _mixInAnnotations . size ();
420
+ return _mixIns . localSize ();
409
421
}
410
- }
422
+ }
0 commit comments