Builder

class Builder : Taggable.Builder<FileSpec.Builder>

Functions

Link copied to clipboard
fun addAliasedImport(className: ClassName, as: String): FileSpec.Builder
fun addAliasedImport(memberName: MemberName, as: String): FileSpec.Builder
fun addAliasedImport(class: Class<*>, as: String): FileSpec.Builder
fun addAliasedImport(class: KClass<*>, as: String): FileSpec.Builder
fun addAliasedImport(    className: ClassName,     memberName: String,     as: String): FileSpec.Builder
Link copied to clipboard
fun addAnnotation(annotationSpec: AnnotationSpec): FileSpec.Builder

Add an annotation to the file.

fun addAnnotation(annotation: ClassName): FileSpec.Builder
fun addAnnotation(annotation: Class<*>): FileSpec.Builder
fun addAnnotation(annotation: KClass<*>): FileSpec.Builder
Link copied to clipboard
fun addBodyComment(format: String, vararg args: Any): FileSpec.Builder

Adds a comment to the body of this script file in the order that it was added.

Link copied to clipboard
fun addCode(codeBlock: CodeBlock): FileSpec.Builder
fun addCode(format: String, vararg args: Any?): FileSpec.Builder
Link copied to clipboard
fun addDefaultPackageImport(packageName: String): FileSpec.Builder

Adds a default import for the given packageName.

Link copied to clipboard
fun addFileComment(format: String, vararg args: Any): FileSpec.Builder

Adds a file-site comment. This is prefixed to the start of the file and different from addBodyComment.

Link copied to clipboard
fun addFunction(funSpec: FunSpec): FileSpec.Builder
Link copied to clipboard
fun addImport(import: Import): FileSpec.Builder
fun addImport(constant: Enum<*>): FileSpec.Builder
fun addImport(className: ClassName, vararg names: String): FileSpec.Builder
fun addImport(className: ClassName, names: Iterable<String>): FileSpec.Builder
fun addImport(class: Class<*>, vararg names: String): FileSpec.Builder
fun addImport(class: Class<*>, names: Iterable<String>): FileSpec.Builder
fun addImport(packageName: String, vararg names: String): FileSpec.Builder
fun addImport(packageName: String, names: Iterable<String>): FileSpec.Builder
fun addImport(class: KClass<*>, vararg names: String): FileSpec.Builder
fun addImport(class: KClass<*>, names: Iterable<String>): FileSpec.Builder
Link copied to clipboard
fun addKotlinDefaultImports(includeJvm: Boolean = true, includeJs: Boolean = true): FileSpec.Builder

Adds Kotlin's standard default package imports as described here.

Link copied to clipboard
fun addNamedCode(format: String, args: Map<String, *>): FileSpec.Builder
Link copied to clipboard
fun addProperty(propertySpec: PropertySpec): FileSpec.Builder
Link copied to clipboard
fun addStatement(format: String, vararg args: Any): FileSpec.Builder
Link copied to clipboard
fun addType(typeSpec: TypeSpec): FileSpec.Builder
Link copied to clipboard
fun addTypeAlias(typeAliasSpec: TypeAliasSpec): FileSpec.Builder
Link copied to clipboard
fun beginControlFlow(controlFlow: String, vararg args: Any): FileSpec.Builder
Link copied to clipboard
fun build(): FileSpec
Link copied to clipboard
fun clearBody(): FileSpec.Builder
Link copied to clipboard
fun clearComment(): FileSpec.Builder
Link copied to clipboard
fun clearImports(): FileSpec.Builder
Link copied to clipboard
fun endControlFlow(): FileSpec.Builder
Link copied to clipboard
fun indent(indent: String): FileSpec.Builder
Link copied to clipboard
fun nextControlFlow(controlFlow: String, vararg args: Any): FileSpec.Builder
Link copied to clipboard
open fun tag(type: Class<*>, tag: Any?): FileSpec.Builder
open fun tag(type: KClass<*>, tag: Any?): FileSpec.Builder

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.

Properties

Link copied to clipboard
val annotations: MutableList<AnnotationSpec>
Link copied to clipboard
val defaultImports: MutableSet<String>
Link copied to clipboard
val imports: List<Import>
Link copied to clipboard
val isScript: Boolean
Link copied to clipboard
val members: MutableList<Any>
Link copied to clipboard
val name: String
Link copied to clipboard
val packageName: String
Link copied to clipboard
open override val tags: MutableMap<KClass<*>, Any>

Mutable map of the current tags this builder contains.

Extensions

Link copied to clipboard
fun FileSpec.Builder.jvmMultifileClass(): FileSpec.Builder
Link copied to clipboard
fun FileSpec.Builder.jvmName(name: String): FileSpec.Builder
Link copied to clipboard
inline fun <T : Any> FileSpec.Builder.tag(tag: T?): FileSpec.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.