|
| 1 | +/** Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. */ |
| 2 | +package com.algolia.client.model.search |
| 3 | + |
| 4 | +import com.algolia.client.exception.AlgoliaClientException |
| 5 | +import com.algolia.client.extensions.internal.* |
| 6 | +import kotlinx.serialization.* |
| 7 | +import kotlinx.serialization.builtins.* |
| 8 | +import kotlinx.serialization.descriptors.* |
| 9 | +import kotlinx.serialization.encoding.* |
| 10 | +import kotlinx.serialization.json.* |
| 11 | +import kotlin.jvm.JvmInline |
| 12 | + |
| 13 | +/** |
| 14 | + * BuiltInOperationValue |
| 15 | + * |
| 16 | + * Implementations: |
| 17 | + * - [Int] - *[BuiltInOperationValue.of]* |
| 18 | + * - [String] - *[BuiltInOperationValue.of]* |
| 19 | + */ |
| 20 | +@Serializable(BuiltInOperationValueSerializer::class) |
| 21 | +public sealed interface BuiltInOperationValue { |
| 22 | + @Serializable |
| 23 | + @JvmInline |
| 24 | + public value class StringValue(public val value: String) : BuiltInOperationValue |
| 25 | + |
| 26 | + @Serializable |
| 27 | + @JvmInline |
| 28 | + public value class IntValue(public val value: Int) : BuiltInOperationValue |
| 29 | + |
| 30 | + public companion object { |
| 31 | + |
| 32 | + public fun of(value: String): BuiltInOperationValue { |
| 33 | + return StringValue(value) |
| 34 | + } |
| 35 | + public fun of(value: Int): BuiltInOperationValue { |
| 36 | + return IntValue(value) |
| 37 | + } |
| 38 | + } |
| 39 | +} |
| 40 | + |
| 41 | +internal class BuiltInOperationValueSerializer : JsonContentPolymorphicSerializer<BuiltInOperationValue>(BuiltInOperationValue::class) { |
| 42 | + override fun selectDeserializer(element: JsonElement): DeserializationStrategy<BuiltInOperationValue> { |
| 43 | + return when { |
| 44 | + element.isString -> BuiltInOperationValue.StringValue.serializer() |
| 45 | + element.isInt -> BuiltInOperationValue.IntValue.serializer() |
| 46 | + else -> throw AlgoliaClientException("Failed to deserialize json element: $element") |
| 47 | + } |
| 48 | + } |
| 49 | +} |
0 commit comments