11/*
2- * Copyright (c) 2021.
2+ * Copyright (c) 2021-2025 .
33 *
44 * This file is part of xmlutil.
55 *
6- * This file is licenced to you under the Apache License, Version 2.0 (the
7- * "License"); you may not use this file except in compliance
8- * with the License. You should have received a copy of the license with the source distribution.
9- * Alternatively, you may obtain a copy of the License at
6+ * This file is licenced to you under the Apache License, Version 2.0
7+ * (the "License"); you may not use this file except in compliance
8+ * with the License. You should have received a copy of the license
9+ * with the source distribution. Alternatively, you may obtain a copy
10+ * of the License at
1011 *
1112 * http://www.apache.org/licenses/LICENSE-2.0
1213 *
13- * Unless required by applicable law or agreed to in writing,
14- * software distributed under the License is distributed on an
15- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16- * KIND, either express or implied. See the License for the
17- * specific language governing permissions and limitations
18- * under the License.
14+ * Unless required by applicable law or agreed to in writing, software
15+ * distributed under the License is distributed on an "AS IS" BASIS,
16+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
17+ * implied. See the License for the specific language governing
18+ * permissions and limitations under the License.
1919 */
2020
2121package nl.adaptivity.serialutil
@@ -25,7 +25,16 @@ import kotlinx.serialization.descriptors.SerialDescriptor
2525import kotlinx.serialization.encoding.Decoder
2626import kotlinx.serialization.encoding.Encoder
2727
28- abstract class DelegatingSerializer <T , D >(val delegateSerializer : KSerializer <D >): KSerializer<T> {
28+ abstract class DelegatingSerializer <T , D >(
29+ serialName : String ,
30+ val delegateSerializer : KSerializer <D >
31+ ): KSerializer<T> {
32+
33+ @Deprecated(" Use serializer that specifies the serial name" )
34+ constructor (delegateSerializer: KSerializer <D >) : this (
35+ delegateSerializer.descriptor.serialName + " _delegate" ,
36+ delegateSerializer
37+ )
2938
3039 abstract fun fromDelegate (delegate : D ): T
3140
@@ -35,7 +44,7 @@ abstract class DelegatingSerializer<T, D>(val delegateSerializer: KSerializer<D>
3544 return fromDelegate(delegateSerializer.deserialize(decoder))
3645 }
3746
38- override val descriptor: SerialDescriptor get() = delegateSerializer.descriptor
47+ override val descriptor: SerialDescriptor = SerialDescriptor (serialName, delegateSerializer.descriptor)
3948
4049 override fun serialize (encoder : Encoder , value : T ) {
4150 delegateSerializer.serialize(encoder, value.toDelegate())
0 commit comments