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

gsonpath.GsonPathTypeAdapterFactoryKt.kt Maven / Gradle / Ivy

package gsonpath

import com.google.gson.Gson
import com.google.gson.TypeAdapter
import com.google.gson.TypeAdapterFactory
import com.google.gson.reflect.TypeToken
import gsonpath.result.GsonResultListTypeAdapterFactory

/**
 * Adds serialization/deserialization handling for GsonPath specific types to Gson.
 *
 * This version of the class proxies to GsonPathTypeAdapterFactory, so it can be used as the sole factory.
 */
class GsonPathTypeAdapterFactoryKt : TypeAdapterFactory {
    override fun  create(gson: Gson, type: TypeToken): TypeAdapter? {
        return gsonPathFactory.create(gson, type) ?: gsonResultListFactory.create(gson, type)
    }

    private val gsonPathFactory by lazy { GsonPathTypeAdapterFactory() }
    private val gsonResultListFactory by lazy { GsonResultListTypeAdapterFactory() }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy