com.avito.android.owner.dependency.JsonOwnedDependenciesSerializer.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of code-ownership Show documentation
Show all versions of code-ownership Show documentation
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()
}
}