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

gsonpath.util.MethodSpecExt.kt Maven / Gradle / Ivy

There is a newer version: 2.0.0
Show newest version
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()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy