File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
src/main/kotlin/com/fasterxml/jackson/module/kotlin Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com.fasterxml.jackson.module.kotlin
2
+
3
+ import com.fasterxml.jackson.databind.ser.std.StdDelegatingSerializer
4
+ import com.fasterxml.jackson.databind.util.StdConverter
5
+ import kotlin.reflect.KClass
6
+
7
+ // S is nullable because value corresponds to a nullable value class
8
+ // @see KotlinNamesAnnotationIntrospector.findNullSerializer
9
+ internal class ValueClassBoxConverter <S : Any ?, D : Any >(
10
+ unboxedClass : Class <S >,
11
+ valueClass : KClass <D >
12
+ ) : StdConverter<S, D>() {
13
+ private val boxMethod = valueClass.java.getDeclaredMethod(" box-impl" , unboxedClass).apply {
14
+ if (! this .isAccessible) this .isAccessible = true
15
+ }
16
+
17
+ @Suppress(" UNCHECKED_CAST" )
18
+ override fun convert (value : S ): D = boxMethod.invoke(null , value) as D
19
+
20
+ val delegatingSerializer: StdDelegatingSerializer by lazy { StdDelegatingSerializer (this ) }
21
+ }
You can’t perform that action at this time.
0 commit comments