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

com.reown.foundation.common.adapters.SubscriptionIdAdapter.kt Maven / Gradle / Ivy

There is a newer version: 1.1.0
Show newest version
package com.reown.foundation.common.adapters

import com.squareup.moshi.*
import com.reown.foundation.common.model.SubscriptionId

internal object SubscriptionIdAdapter: JsonAdapter() {

    @JvmSynthetic
    @FromJson
    @Qualifier
    override fun fromJson(reader: JsonReader): SubscriptionId? {
        reader.isLenient = true
        var subscriptionId: String? = null

        if (reader.hasNext() && reader.peek() == JsonReader.Token.STRING) {
            subscriptionId = reader.nextString()
        }

        return if (subscriptionId != null) {
            SubscriptionId(subscriptionId)
        } else {
            null
        }
    }

    @JvmSynthetic
    @ToJson
    override fun toJson(writer: JsonWriter, @Qualifier value: SubscriptionId?) {
        if (value != null) {
            writer.value(value.id)
        } else {
            writer.value("")
        }
    }

    @Retention(AnnotationRetention.RUNTIME)
    @JsonQualifier
    annotation class Qualifier
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy