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

gsonpath.adapter.AdapterMethodBuilder.kt Maven / Gradle / Ivy

Go to download

An annotation processor which generates Type Adapters for the Google Gson library

The newest version!
package gsonpath.adapter

import com.google.gson.stream.JsonReader
import com.google.gson.stream.JsonWriter
import com.squareup.javapoet.TypeName
import gsonpath.util.MethodSpecExt
import java.io.IOException

object AdapterMethodBuilder {
    fun createReadMethodBuilder(returnTypeName: TypeName) = MethodSpecExt.overrideMethodBuilder("readImpl").apply {
        returns(returnTypeName)
        addParameter(JsonReader::class.java, Constants.IN)
        addException(IOException::class.java)
    }

    fun createWriteMethodBuilder(writtenValueTypeName: TypeName) = MethodSpecExt.overrideMethodBuilder("writeImpl").apply {
        addParameter(JsonWriter::class.java, Constants.OUT)
        addParameter(writtenValueTypeName, Constants.VALUE)
        addException(IOException::class.java)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy