@@ -32,7 +32,21 @@ fun Class<*>.isKotlinClass(): Boolean {
32
32
* (e.g. List<String>) may contain null values after deserialization. Enabling it
33
33
* protects against this but has significant performance impact.
34
34
*/
35
- class KotlinModule @Deprecated(level = DeprecationLevel .WARNING , message = " Use KotlinModule.Builder" ) constructor(
35
+ class KotlinModule @Deprecated(
36
+ level = DeprecationLevel .WARNING ,
37
+ message = " Use KotlinModule.Builder instead of named constructor parameters." ,
38
+ replaceWith = ReplaceWith (
39
+ """ KotlinModule.Builder()
40
+ .withReflectionCacheSize(reflectionCacheSize)
41
+ .configure(KotlinFeature.NullToEmptyCollection, nullToEmptyCollection)
42
+ .configure(KotlinFeature.NullToEmptyMap, nullToEmptyMap)
43
+ .configure(KotlinFeature.NullIsSameAsDefault, nullIsSameAsDefault)
44
+ .configure(KotlinFeature.SingletonSupport, singletonSupport)
45
+ .configure(KotlinFeature.StrictNullChecks, strictNullChecks)
46
+ .build()""" ,
47
+ " com.fasterxml.jackson.module.kotlin.KotlinFeature"
48
+ )
49
+ ) constructor(
36
50
val reflectionCacheSize : Int = 512 ,
37
51
val nullToEmptyCollection : Boolean = false ,
38
52
val nullToEmptyMap : Boolean = false ,
@@ -129,100 +143,141 @@ class KotlinModule @Deprecated(level = DeprecationLevel.WARNING, message = "Use
129
143
KotlinFeature .values().filter { it.enabledByDefault }.forEach { or (it.bitSet) }
130
144
}
131
145
132
- fun withReflectionCacheSize (reflectionCacheSize : Int ) = apply {
146
+ fun withReflectionCacheSize (reflectionCacheSize : Int ): Builder = apply {
133
147
this .reflectionCacheSize = reflectionCacheSize
134
148
}
135
149
136
- fun enable (feature : KotlinFeature ) = apply {
150
+ fun enable (feature : KotlinFeature ): Builder = apply {
137
151
bitSet.or (feature.bitSet)
138
152
}
139
153
140
- fun disable (feature : KotlinFeature ) = apply {
154
+ fun disable (feature : KotlinFeature ): Builder = apply {
141
155
bitSet.andNot(feature.bitSet)
142
156
}
143
157
144
- fun configure (feature : KotlinFeature , enabled : Boolean ) = when {
145
- enabled -> enable(feature)
146
- else -> disable(feature)
147
- }
158
+ fun configure (feature : KotlinFeature , enabled : Boolean ): Builder =
159
+ when {
160
+ enabled -> enable(feature)
161
+ else -> disable(feature)
162
+ }
148
163
149
- fun isEnabled (feature : KotlinFeature ): Boolean = bitSet.intersects(feature.bitSet)
164
+ fun isEnabled (feature : KotlinFeature ): Boolean =
165
+ bitSet.intersects(feature.bitSet)
150
166
151
167
@Deprecated(
152
168
message = " Deprecated, use withReflectionCacheSize(reflectionCacheSize) instead." ,
153
- replaceWith = ReplaceWith (" isEnabled (reflectionCacheSize)" )
169
+ replaceWith = ReplaceWith (" withReflectionCacheSize (reflectionCacheSize)" )
154
170
)
155
- fun reflectionCacheSize (reflectionCacheSize : Int ) = apply {
156
- this .reflectionCacheSize = reflectionCacheSize
157
- }
171
+ fun reflectionCacheSize (reflectionCacheSize : Int ): Builder =
172
+ withReflectionCacheSize(reflectionCacheSize)
158
173
159
174
@Deprecated(
160
175
message = " Deprecated, use isEnabled(NullToEmptyCollection) instead." ,
161
- replaceWith = ReplaceWith (" isEnabled(NullToEmptyCollection)" )
176
+ replaceWith = ReplaceWith (
177
+ " isEnabled(KotlinFeature.NullToEmptyCollection)" ,
178
+ " com.fasterxml.jackson.module.kotlin.KotlinFeature"
179
+ )
162
180
)
163
- fun getNullToEmptyCollection () = isEnabled(NullToEmptyCollection )
181
+ fun getNullToEmptyCollection (): Boolean =
182
+ isEnabled(NullToEmptyCollection )
164
183
165
184
@Deprecated(
166
185
message = " Deprecated, use configure(NullToEmptyCollection, enabled) instead." ,
167
- replaceWith = ReplaceWith (" configure(NullToEmptyCollection, enabled)" )
186
+ replaceWith = ReplaceWith (
187
+ " configure(KotlinFeature.NullToEmptyCollection, nullToEmptyCollection)" ,
188
+ " com.fasterxml.jackson.module.kotlin.KotlinFeature"
189
+ )
168
190
)
169
- fun nullToEmptyCollection (nullToEmptyCollection : Boolean ) =
191
+ fun nullToEmptyCollection (nullToEmptyCollection : Boolean ): Builder =
170
192
configure(NullToEmptyCollection , nullToEmptyCollection)
171
193
172
194
@Deprecated(
173
195
message = " Deprecated, use isEnabled(NullToEmptyMap) instead." ,
174
- replaceWith = ReplaceWith (" isEnabled(NullToEmptyMap)" )
196
+ replaceWith = ReplaceWith (
197
+ " isEnabled(KotlinFeature.NullToEmptyMap)" ,
198
+ " com.fasterxml.jackson.module.kotlin.KotlinFeature"
199
+ )
175
200
)
176
- fun getNullToEmptyMap () = isEnabled(NullToEmptyMap )
201
+ fun getNullToEmptyMap (): Boolean =
202
+ isEnabled(NullToEmptyMap )
177
203
178
204
@Deprecated(
179
205
message = " Deprecated, use configure(NullToEmptyMap, enabled) instead." ,
180
- replaceWith = ReplaceWith (" configure(NullToEmptyMap, enabled)" )
206
+ replaceWith = ReplaceWith (
207
+ " configure(KotlinFeature.NullToEmptyMap, nullToEmptyMap)" ,
208
+ " com.fasterxml.jackson.module.kotlin.KotlinFeature"
209
+ )
181
210
)
182
- fun nullToEmptyMap (nullToEmptyMap : Boolean ) = configure(NullToEmptyMap , nullToEmptyMap)
211
+ fun nullToEmptyMap (nullToEmptyMap : Boolean ): Builder =
212
+ configure(NullToEmptyMap , nullToEmptyMap)
183
213
184
214
@Deprecated(
185
215
message = " Deprecated, use isEnabled(NullIsSameAsDefault) instead." ,
186
- replaceWith = ReplaceWith (" isEnabled(NullIsSameAsDefault)" )
216
+ replaceWith = ReplaceWith (
217
+ " isEnabled(KotlinFeature.NullIsSameAsDefault)" ,
218
+ " com.fasterxml.jackson.module.kotlin.KotlinFeature"
219
+ )
187
220
)
188
- fun getNullIsSameAsDefault () = isEnabled(NullIsSameAsDefault )
221
+ fun getNullIsSameAsDefault (): Boolean =
222
+ isEnabled(NullIsSameAsDefault )
189
223
190
224
@Deprecated(
191
225
message = " Deprecated, use configure(NullIsSameAsDefault, enabled) instead." ,
192
- replaceWith = ReplaceWith (" configure(NullIsSameAsDefault, enabled)" )
226
+ replaceWith = ReplaceWith (
227
+ " configure(KotlinFeature.NullIsSameAsDefault, nullIsSameAsDefault)" ,
228
+ " com.fasterxml.jackson.module.kotlin.KotlinFeature"
229
+ )
193
230
)
194
- fun nullIsSameAsDefault (nullIsSameAsDefault : Boolean ) = configure(NullIsSameAsDefault , nullIsSameAsDefault)
231
+ fun nullIsSameAsDefault (nullIsSameAsDefault : Boolean ): Builder =
232
+ configure(NullIsSameAsDefault , nullIsSameAsDefault)
195
233
196
234
@Deprecated(
197
235
message = " Deprecated, use isEnabled(SingletonSupport) instead." ,
198
- replaceWith = ReplaceWith (" isEnabled(SingletonSupport)" )
236
+ replaceWith = ReplaceWith (
237
+ " isEnabled(KotlinFeature.SingletonSupport)" ,
238
+ " com.fasterxml.jackson.module.kotlin.KotlinFeature"
239
+ )
199
240
)
200
- fun getSingletonSupport () = when {
201
- isEnabled(KotlinFeature .SingletonSupport ) -> CANONICALIZE
202
- else -> DISABLED
203
- }
241
+ fun getSingletonSupport (): SingletonSupport =
242
+ when {
243
+ isEnabled(KotlinFeature .SingletonSupport ) -> CANONICALIZE
244
+ else -> DISABLED
245
+ }
204
246
205
247
@Deprecated(
206
248
message = " Deprecated, use configure(SingletonSupport, enabled) instead." ,
207
- replaceWith = ReplaceWith (" configure(SingletonSupport, enabled)" )
249
+ replaceWith = ReplaceWith (
250
+ " configure(KotlinFeature.SingletonSupport, singletonSupport)" ,
251
+ " com.fasterxml.jackson.module.kotlin.KotlinFeature"
252
+ )
208
253
)
209
- fun singletonSupport (singletonSupport : SingletonSupport ) = when (singletonSupport) {
210
- CANONICALIZE -> enable(KotlinFeature .SingletonSupport )
211
- else -> disable(KotlinFeature .SingletonSupport )
212
- }
254
+ fun singletonSupport (singletonSupport : SingletonSupport ): Builder =
255
+ when (singletonSupport) {
256
+ CANONICALIZE -> enable(KotlinFeature .SingletonSupport )
257
+ else -> disable(KotlinFeature .SingletonSupport )
258
+ }
213
259
214
260
@Deprecated(
215
261
message = " Deprecated, use isEnabled(StrictNullChecks) instead." ,
216
- replaceWith = ReplaceWith (" isEnabled(StrictNullChecks)" )
262
+ replaceWith = ReplaceWith (
263
+ " isEnabled(KotlinFeature.StrictNullChecks)" ,
264
+ " com.fasterxml.jackson.module.kotlin.KotlinFeature"
265
+ )
217
266
)
218
- fun getStrictNullChecks () = isEnabled(StrictNullChecks )
267
+ fun getStrictNullChecks (): Boolean =
268
+ isEnabled(StrictNullChecks )
219
269
220
270
@Deprecated(
221
271
message = " Deprecated, use configure(StrictNullChecks, enabled) instead." ,
222
- replaceWith = ReplaceWith (" configure(StrictNullChecks, enabled)" )
272
+ replaceWith = ReplaceWith (
273
+ " configure(KotlinFeature.StrictNullChecks, strictNullChecks)" ,
274
+ " com.fasterxml.jackson.module.kotlin.KotlinFeature"
275
+ )
223
276
)
224
- fun strictNullChecks (strictNullChecks : Boolean ) = configure(StrictNullChecks , strictNullChecks)
277
+ fun strictNullChecks (strictNullChecks : Boolean ): Builder =
278
+ configure(StrictNullChecks , strictNullChecks)
225
279
226
- fun build () = KotlinModule (this )
280
+ fun build (): KotlinModule =
281
+ KotlinModule (this )
227
282
}
228
283
}
0 commit comments