All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.com.xebia.functional.openai.generated.model.MessageContentTextObjectTextAnnotationsInner.kt Maven / Gradle / Ivy

There is a newer version: 0.0.5-alpha.118
Show newest version
/**
 *
 * Please note:
 * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * Do not edit this file manually.
 *
 */

@file:Suppress(
    "ArrayInDataClass",
    "EnumEntryName",
    "RemoveRedundantQualifierName",
    "UnusedImport"
)

package com.xebia.functional.openai.generated.model

import com.xebia.functional.openai.generated.model.MessageContentTextAnnotationsFileCitationObject
import com.xebia.functional.openai.generated.model.MessageContentTextAnnotationsFileCitationObjectFileCitation
import com.xebia.functional.openai.generated.model.MessageContentTextAnnotationsFilePathObject
import com.xebia.functional.openai.generated.model.MessageContentTextAnnotationsFilePathObjectFilePath
import com.xebia.functional.openai.attemptDeserialize
import kotlin.jvm.JvmInline
import kotlinx.serialization.*
import kotlinx.serialization.builtins.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*
import kotlinx.serialization.json.*

@Serializable(with = MessageContentTextObjectTextAnnotationsInnerSerializer::class)
sealed interface MessageContentTextObjectTextAnnotationsInner {

  @JvmInline
  @Serializable
  value class CaseMessageContentTextAnnotationsFileCitationObject(val value: MessageContentTextAnnotationsFileCitationObject): MessageContentTextObjectTextAnnotationsInner
  @JvmInline
  @Serializable
  value class CaseMessageContentTextAnnotationsFilePathObject(val value: MessageContentTextAnnotationsFilePathObject): MessageContentTextObjectTextAnnotationsInner

}

object MessageContentTextObjectTextAnnotationsInnerSerializer : KSerializer {
    @OptIn(InternalSerializationApi::class, ExperimentalSerializationApi::class)
    override val descriptor: SerialDescriptor = buildSerialDescriptor("MessageContentTextObjectTextAnnotationsInner", PolymorphicKind.SEALED) { 
      element("1", MessageContentTextAnnotationsFileCitationObject.serializer().descriptor)
      element("2", MessageContentTextAnnotationsFilePathObject.serializer().descriptor)
    }

    override fun deserialize(decoder: Decoder): MessageContentTextObjectTextAnnotationsInner {
      val jsonSerde = Json { ignoreUnknownKeys = true }
      val json = decoder.decodeSerializableValue(JsonElement.serializer())
      return attemptDeserialize(json, 
        Pair(MessageContentTextObjectTextAnnotationsInner.CaseMessageContentTextAnnotationsFileCitationObject::class) {
          MessageContentTextObjectTextAnnotationsInner.CaseMessageContentTextAnnotationsFileCitationObject(jsonSerde.decodeFromJsonElement(MessageContentTextAnnotationsFileCitationObject.serializer(), json))
      },
        Pair(MessageContentTextObjectTextAnnotationsInner.CaseMessageContentTextAnnotationsFilePathObject::class) {
          MessageContentTextObjectTextAnnotationsInner.CaseMessageContentTextAnnotationsFilePathObject(jsonSerde.decodeFromJsonElement(MessageContentTextAnnotationsFilePathObject.serializer(), json))
      })
    }

    override fun serialize(encoder: Encoder, value: MessageContentTextObjectTextAnnotationsInner) =
      when(value) { 
        is MessageContentTextObjectTextAnnotationsInner.CaseMessageContentTextAnnotationsFileCitationObject ->
        encoder.encodeSerializableValue(MessageContentTextAnnotationsFileCitationObject.serializer(), value.value)

        is MessageContentTextObjectTextAnnotationsInner.CaseMessageContentTextAnnotationsFilePathObject ->
        encoder.encodeSerializableValue(MessageContentTextAnnotationsFilePathObject.serializer(), value.value)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy