@@ -109,44 +109,3 @@ internal class KotlinSerializers : Serializers.Base() {
109
109
}
110
110
}
111
111
}
112
-
113
- // This serializer is used to properly serialize the value class.
114
- // The getter generated for the value class is special,
115
- // so this class will not work properly when added to the Serializers
116
- // (it is configured from KotlinAnnotationIntrospector.findSerializer).
117
- internal class ValueClassBoxSerializer <T : Any >(
118
- private val outerClazz : Class <out Any >, innerClazz : Class <T >
119
- ) : StdSerializer<T>(innerClazz) {
120
- private val boxMethod = outerClazz.getMethod(" box-impl" , innerClazz)
121
-
122
- override fun serialize (value : T ? , gen : JsonGenerator , provider : SerializerProvider ) {
123
- // Values retrieved from getter are considered validated and constructor-impl is not executed.
124
- val boxed = boxMethod.invoke(null , value)
125
-
126
- provider.findValueSerializer(outerClazz).serialize(boxed, gen, provider)
127
- }
128
- }
129
-
130
- internal class ValueClassStaticJsonValueSerializer <T > private constructor(
131
- innerClazz : Class <T >,
132
- private val staticJsonValueGetter : Method
133
- ) : StdSerializer<T>(innerClazz) {
134
- override fun serialize (value : T ? , gen : JsonGenerator , provider : SerializerProvider ) {
135
- // As shown in the processing of the factory function, jsonValueGetter is always a static method.
136
- val jsonValue: Any? = staticJsonValueGetter.invoke(null , value)
137
- jsonValue
138
- ?.let { provider.findValueSerializer(it::class .java).serialize(it, gen, provider) }
139
- ? : provider.findNullValueSerializer(null ).serialize(null , gen, provider)
140
- }
141
-
142
- // Since JsonValue can be processed correctly if it is given to a non-static getter/field,
143
- // this class will only process if it is a `static` method.
144
- companion object {
145
- fun <T > createdOrNull (
146
- outerClazz : Class <out Any >,
147
- innerClazz : Class <T >
148
- ): ValueClassStaticJsonValueSerializer <T >? = outerClazz
149
- .getStaticJsonValueGetter()
150
- ?.let { ValueClassStaticJsonValueSerializer (innerClazz, it) }
151
- }
152
- }
0 commit comments