kotlinpoet / com.squareup.kotlinpoet / FileSpec

FileSpec

class FileSpec : Taggable

A Kotlin file containing top level objects like classes, objects, functions, properties, and type aliases.

Items are output in the following order:

Types

Builder

class Builder : Taggable.Builder<FileSpec.Builder>

Properties

annotations

val annotations: List<AnnotationSpec>

comment

val comment: CodeBlock

members

val members: List<Any>

name

val name: String

packageName

val packageName: String

Functions

equals

fun equals(other: Any?): Boolean

hashCode

fun hashCode(): Int

toBuilder

fun toBuilder(): FileSpec.Builder

toJavaFileObject

fun toJavaFileObject(): JavaFileObject

toString

fun toString(): String

writeTo

fun writeTo(out: Appendable): Unitfun writeTo(directory: Path): Unit
fun writeTo(directory: File): Unit

Writes this to directory as UTF-8 using the standard directory structure.

fun writeTo(filer: Filer): Unit

Writes this to filer.

Companion Object Functions

builder

fun builder(packageName: String, fileName: String): FileSpec.Builder

get

fun get(packageName: String, typeSpec: TypeSpec): FileSpec

Extension Functions

tag

fun <T : Any> Taggable.tag(): T?

Returns the tag attached with T as a key, or null if no tag is attached with that key.