andrew
01/31/2023, 11:03 PM@Serializable
class DormaKabaKey(private val file: NeonFile) : Key<NeonFile>, NeonFile by file {
@SerialName("fileId")
private val fileId: ByteArray? = file.fileId
@SerialName("fileDefinitionName")
private val fileDefinitionName: String? = file.fileDefinitionName
override fun getFileId() = fileId
override fun hasFileId() = fileId !== null
override fun getFileDefinitionName() = fileDefinitionName
override fun hasFileDefinitionName() = fileDefinitionName !== null
}
For context, I'm using a proprietary library with NO caching support which is why I'm serializing their door lock credential type, and I have omitted many fields
The better way to put it, I don't care about NeonFile or the impl, only my class and its values where it'll be then be reconstructed when being deserialized.kotlinx.serialization.SerializationException: Class 'b' is not registered for polymorphic serialization in the scope of 'NeonFile'.
Mark the base class as 'sealed' or register the serializer explicitly.
at kotlinx.serialization.internal.AbstractPolymorphicSerializerKt.throwSubtypeNotRegistered(AbstractPolymorphicSerializer.kt:102)
at kotlinx.serialization.internal.AbstractPolymorphicSerializerKt.throwSubtypeNotRegistered(AbstractPolymorphicSerializer.kt:113)
at kotlinx.serialization.PolymorphicSerializerKt.findPolymorphicSerializer(PolymorphicSerializer.kt:109)
at kotlinx.serialization.internal.AbstractPolymorphicSerializer.serialize(AbstractPolymorphicSerializer.kt:32)
at kotlinx.serialization.protobuf.internal.ProtobufEncoder.encodeSerializableValue(ProtobufEncoding.kt:138)
at kotlinx.serialization.protobuf.internal.ProtobufTaggedEncoder.encodeSerializableElement(ProtobufTaggedEncoder.kt:135)
at com.stratisiot.stratissdk.keyring.key.DormaKabaKey.write$Self(DormaKabaKey.kt:8)
at com.stratisiot.stratissdk.keyring.key.DormaKabaKey$$serializer.serialize(DormaKabaKey.kt:8)
at com.stratisiot.stratissdk.keyring.key.DormaKabaKey$$serializer.serialize(DormaKabaKey.kt:8)
at kotlinx.serialization.protobuf.internal.ProtobufEncoder.encodeSerializableValue(ProtobufEncoding.kt:138)
at kotlinx.serialization.protobuf.ProtoBuf.encodeToByteArray(ProtoBuf.kt:130)
pdvrieze
02/01/2023, 2:14 PMNeonFile
to be serializable/have a serializer (which it doesn't appear to be based upon your posted errors).andrew
02/01/2023, 2:25 PMpdvrieze
02/01/2023, 2:45 PMfile
property as Serializable
with the type of the actual serializer to use (the proprietary one should work correctly due to erasure, but you could write your own little wrapper).andrew
02/01/2023, 2:53 PM