kotlinpoet / com.squareup.kotlinpoet / TypeSpec / Builder

Builder

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

Properties

annotationSpecs

val annotationSpecs: MutableList<AnnotationSpec>

enumConstants

val enumConstants: MutableMap<String, TypeSpec>

funSpecs

val funSpecs: MutableList<FunSpec>

modifiers

val modifiers: MutableSet<KModifier>

originatingElements

val originatingElements: MutableList<Element>

Mutable map of the current originating elements this builder contains.

propertySpecs

val propertySpecs: MutableList<PropertySpec>

superclassConstructorParameters

val superclassConstructorParameters: MutableList<CodeBlock>

superinterfaces

val superinterfaces: MutableMap<TypeName, CodeBlock?>

tags

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

Mutable map of the current tags this builder contains.

typeSpecs

val typeSpecs: MutableList<TypeSpec>

typeVariables

val typeVariables: MutableList<TypeVariableName>

Functions

addAnnotation

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

addAnnotations

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

addEnumConstant

fun addEnumConstant(name: String, typeSpec: TypeSpec = anonymousClassBuilder().build()): TypeSpec.Builder

addFunction

fun addFunction(funSpec: FunSpec): TypeSpec.Builder

addFunctions

fun addFunctions(funSpecs: Iterable<FunSpec>): TypeSpec.Builder

addInitializerBlock

fun addInitializerBlock(block: CodeBlock): TypeSpec.Builder

addKdoc

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

addModifiers

fun addModifiers(vararg modifiers: KModifier): TypeSpec.Builder

addProperties

fun addProperties(propertySpecs: Iterable<PropertySpec>): TypeSpec.Builder

addProperty

fun addProperty(propertySpec: PropertySpec): TypeSpec.Builder
fun addProperty(name: String, type: TypeName, vararg modifiers: KModifier): TypeSpec.Builder
fun addProperty(name: String, type: Type, vararg modifiers: KModifier): TypeSpec.Builder
fun addProperty(name: String, type: KClass<*>, vararg modifiers: KModifier): TypeSpec.Builder

addSuperclassConstructorParameter

fun addSuperclassConstructorParameter(format: String, vararg args: Any): TypeSpec.Builder
fun addSuperclassConstructorParameter(codeBlock: CodeBlock): TypeSpec.Builder

addSuperinterface

fun addSuperinterface(superinterface: TypeName, delegate: CodeBlock = CodeBlock.EMPTY): TypeSpec.Builder
fun addSuperinterface(superinterface: Type, delegate: CodeBlock = CodeBlock.EMPTY): TypeSpec.Builder
fun addSuperinterface(superinterface: KClass<*>, delegate: CodeBlock = CodeBlock.EMPTY): TypeSpec.Builder
fun addSuperinterface(superinterface: KClass<*>, constructorParameterName: String): TypeSpec.Builder
fun addSuperinterface(superinterface: TypeName, constructorParameter: String): TypeSpec.Builder

addSuperinterfaces

fun addSuperinterfaces(superinterfaces: Iterable<TypeName>): TypeSpec.Builder

addType

fun addType(typeSpec: TypeSpec): TypeSpec.Builder

addTypes

fun addTypes(typeSpecs: Iterable<TypeSpec>): TypeSpec.Builder

addTypeVariable

fun addTypeVariable(typeVariable: TypeVariableName): TypeSpec.Builder

addTypeVariables

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

build

fun build(): TypeSpec

primaryConstructor

fun primaryConstructor(primaryConstructor: FunSpec?): TypeSpec.Builder

superclass

fun superclass(superclass: TypeName): TypeSpec.Builder
fun superclass(superclass: Type): TypeSpec.Builder
fun superclass(superclass: KClass<*>): TypeSpec.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

jvmSuppressWildcards

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

tag

fun <T : Any> TypeSpec.Builder.tag(tag: T?): TypeSpec.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.