gsonpath.util.MethodSpecExt.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gsonpath-compiler-base Show documentation
Show all versions of gsonpath-compiler-base Show documentation
An annotation processor which generates Type Adapters for the Google Gson library
package gsonpath.util
import com.squareup.javapoet.CodeBlock
import com.squareup.javapoet.MethodSpec
import javax.lang.model.element.Modifier
object MethodSpecExt {
fun overrideMethodBuilder(name: String): MethodSpec.Builder {
return MethodSpec.methodBuilder(name)
.addAnnotation(Override::class.java)
.addModifiers(Modifier.PUBLIC)
}
}
fun MethodSpec.Builder.code(func: CodeBlock.Builder.() -> Unit): MethodSpec.Builder {
return addCode(CodeBlock.builder().applyAndBuild(func))
}
fun MethodSpec.Builder.applyAndBuild(func: MethodSpec.Builder.() -> Unit): MethodSpec {
return apply(func).build()
}