Skip to content

Commit

Permalink
remove useless InlineDecoder as it is natively handled now
Browse files Browse the repository at this point in the history
  • Loading branch information
Chuckame committed Jan 29, 2024
1 parent 91dea8e commit f6b186e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 29 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,7 @@ class RecordDecoder(
override fun beginStructure(descriptor: SerialDescriptor): CompositeDecoder {
val value = fieldValue()
return when (descriptor.kind) {
StructureKind.CLASS ->
if (descriptor.isInline) {
InlineDecoder(fieldValue(), serializersModule)
} else {
RecordDecoder(descriptor, value as GenericRecord, serializersModule, configuration)
}
StructureKind.CLASS -> RecordDecoder(descriptor, value as GenericRecord, serializersModule, configuration)
StructureKind.MAP ->
MapDecoder(
descriptor,
Expand All @@ -54,6 +49,7 @@ class RecordDecoder(
serializersModule,
configuration
)

StructureKind.LIST -> {
val decoder: CompositeDecoder =
if (descriptor.getElementDescriptor(0).kind == PrimitiveKind.BYTE) {
Expand All @@ -74,13 +70,15 @@ class RecordDecoder(
}
decoder
}

PolymorphicKind.SEALED, PolymorphicKind.OPEN ->
UnionDecoder(
descriptor,
value as GenericRecord,
serializersModule,
configuration
)

else -> throw UnsupportedOperationException("Decoding descriptor of kind ${descriptor.kind} is currently not supported")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.github.avrokotlin.avro4k.encoder
import com.github.avrokotlin.avro4k.ListRecord
import com.github.avrokotlin.avro4k.Record
import com.github.avrokotlin.avro4k.schema.extractNonNull
import com.github.avrokotlin.avro4k.schema.unwrapValueClass
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.SerializationException
import kotlinx.serialization.descriptors.PolymorphicKind
Expand All @@ -21,7 +22,7 @@ interface StructureEncoder : FieldEncoder {
override fun beginStructure(descriptor: SerialDescriptor): CompositeEncoder {
return when (descriptor.kind) {
StructureKind.LIST -> {
when (descriptor.getElementDescriptor(0).kind) {
when (descriptor.getElementDescriptor(0).unwrapValueClass.kind) {
PrimitiveKind.BYTE -> ByteArrayEncoder(fieldSchema(), serializersModule) { addValue(it) }
else -> ListEncoder(fieldSchema(), serializersModule) { addValue(it) }
}
Expand Down

0 comments on commit f6b186e

Please sign in to comment.