gsonpath.adapter.AdapterMethodBuilder.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gsonpath-compiler Show documentation
Show all versions of gsonpath-compiler Show documentation
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)
}
}