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

com.avito.android.owner.dependency.JsonOwnedDependenciesSerializer.kt Maven / Gradle / Ivy

Go to download

Collection of infrastructure libraries and gradle plugins of Avito Android project

The newest version!
package com.avito.android.owner.dependency

import com.avito.android.info.di.MoshiProvider
import com.avito.android.owner.adapter.OwnerAdapterFactory
import com.squareup.moshi.adapter

public class JsonOwnedDependenciesSerializer(
    ownersAdapterFactory: OwnerAdapterFactory
) : OwnedDependenciesSerializer {

    @OptIn(ExperimentalStdlibApi::class)
    private val jsonAdapter = MoshiProvider(ownersAdapterFactory).provide().adapter>()

    override fun serialize(ownedDependencies: List): String {
        return jsonAdapter.toJson(ownedDependencies)
    }

    override fun deserialize(rawDependenciesText: String): List {
        return jsonAdapter.fromJson(rawDependenciesText) ?: listOf()
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy