kotlinpoet / com.squareup.kotlinpoet / FunSpec / Builder

Builder

class Builder : Taggable.Builder<FunSpec.Builder>, OriginatingElementsHolder.Builder<FunSpec.Builder>

Properties

annotations

val annotations: MutableList<AnnotationSpec>

modifiers

val modifiers: MutableList<KModifier>

originatingElements

val originatingElements: MutableList<Element>

Mutable map of the current originating elements this builder contains.

parameters

val parameters: MutableList<ParameterSpec>

tags

val tags: MutableMap<KClass<*>, Any>

Mutable map of the current tags this builder contains.

typeVariables

val typeVariables: MutableList<TypeVariableName>

Functions

addAnnotation

fun addAnnotation(annotationSpec: AnnotationSpec): FunSpec.Builder
fun addAnnotation(annotation: ClassName): FunSpec.Builder
fun addAnnotation(annotation: Class<*>): FunSpec.Builder
fun addAnnotation(annotation: KClass<*>): FunSpec.Builder

addAnnotations

fun addAnnotations(annotationSpecs: Iterable<AnnotationSpec>): FunSpec.Builder

addCode

fun addCode(format: String, vararg args: Any?): FunSpec.Builder
fun addCode(codeBlock: CodeBlock): FunSpec.Builder

addComment

fun addComment(format: String, vararg args: Any): FunSpec.Builder

addKdoc

fun addKdoc(format: String, vararg args: Any): FunSpec.Builder
fun addKdoc(block: CodeBlock): FunSpec.Builder

addModifiers

fun addModifiers(vararg modifiers: KModifier): FunSpec.Builder
fun addModifiers(modifiers: Iterable<KModifier>): FunSpec.Builder

addNamedCode

fun addNamedCode(format: String, args: Map<String, *>): FunSpec.Builder

addParameter

fun addParameter(parameterSpec: ParameterSpec): FunSpec.Builder
fun addParameter(name: String, type: TypeName, vararg modifiers: KModifier): FunSpec.Builder
fun addParameter(name: String, type: Type, vararg modifiers: KModifier): FunSpec.Builder
fun addParameter(name: String, type: KClass<*>, vararg modifiers: KModifier): FunSpec.Builder

addParameters

fun addParameters(parameterSpecs: Iterable<ParameterSpec>): FunSpec.Builder

addStatement

fun addStatement(format: String, vararg args: Any): FunSpec.Builder

addTypeVariable

fun addTypeVariable(typeVariable: TypeVariableName): FunSpec.Builder

addTypeVariables

fun addTypeVariables(typeVariables: Iterable<TypeVariableName>): FunSpec.Builder

beginControlFlow

fun beginControlFlow(controlFlow: String, vararg args: Any): FunSpec.Builder

build

fun build(): FunSpec

callSuperConstructor

fun callSuperConstructor(vararg args: String): FunSpec.Builder
fun callSuperConstructor(vararg args: CodeBlock = emptyArray()): FunSpec.Builder

callThisConstructor

fun callThisConstructor(vararg args: String): FunSpec.Builder
fun callThisConstructor(vararg args: CodeBlock = emptyArray()): FunSpec.Builder

endControlFlow

fun endControlFlow(): FunSpec.Builder

jvmModifiers

fun jvmModifiers(modifiers: Iterable<Modifier>): Unit

nextControlFlow

fun nextControlFlow(controlFlow: String, vararg args: Any): FunSpec.Builder

receiver

fun receiver(receiverType: TypeName, kdoc: CodeBlock = CodeBlock.EMPTY): FunSpec.Builder
fun receiver(receiverType: Type, kdoc: CodeBlock = CodeBlock.EMPTY): FunSpec.Builder
fun receiver(receiverType: Type, kdoc: String, vararg args: Any): FunSpec.Builder
fun receiver(receiverType: KClass<*>, kdoc: CodeBlock = CodeBlock.EMPTY): FunSpec.Builder
fun receiver(receiverType: KClass<*>, kdoc: String, vararg args: Any): FunSpec.Builder

returns

fun returns(returnType: TypeName, kdoc: CodeBlock = CodeBlock.EMPTY): FunSpec.Builder
fun returns(returnType: Type, kdoc: CodeBlock = CodeBlock.EMPTY): FunSpec.Builder
fun returns(returnType: Type, kdoc: String, vararg args: Any): FunSpec.Builder
fun returns(returnType: KClass<*>, kdoc: CodeBlock = CodeBlock.EMPTY): FunSpec.Builder
fun returns(returnType: KClass<*>, kdoc: String, vararg args: Any): FunSpec.Builder

Inherited Functions

addOriginatingElement

open fun addOriginatingElement(originatingElement: Element): T

Adds an originatingElement to this type's list of originating elements.

tag

open fun tag(type: Class<*>, tag: Any?): T
open fun tag(type: KClass<*>, tag: Any?): T

Attaches tag to the request using type as a key. Tags can be read from a request using Taggable.tag. Use null to remove any existing tag assigned for type.

Extension Functions

jvmDefault

fun FunSpec.Builder.jvmDefault(): FunSpec.Builder

jvmName

fun FunSpec.Builder.jvmName(name: String): FunSpec.Builder

jvmOverloads

fun FunSpec.Builder.jvmOverloads(): FunSpec.Builder

jvmStatic

fun FunSpec.Builder.jvmStatic(): FunSpec.Builder

jvmSuppressWildcards

fun FunSpec.Builder.jvmSuppressWildcards(suppress: Boolean = true): FunSpec.Builder

strictfp

fun FunSpec.Builder.strictfp(): FunSpec.Builder

synchronized

fun FunSpec.Builder.synchronized(): FunSpec.Builder

tag

fun <T : Any> FunSpec.Builder.tag(tag: T?): FunSpec.Builder

Attaches tag to the request using T as a key. Tags can be read from a request using Taggable.tag. Use null to remove any existing tag assigned for T.

throws

fun FunSpec.Builder.throws(vararg exceptionClasses: KClass<out Throwable>): FunSpec.Builder
fun FunSpec.Builder.throws(vararg exceptionClasses: Type): FunSpec.Builder
fun FunSpec.Builder.throws(vararg exceptionClasses: TypeName): FunSpec.Builder