kotlinpoet / com.squareup.kotlinpoet

Package com.squareup.kotlinpoet

Types

AnnotationSpec

class AnnotationSpec

A generated annotation on a declaration.

ClassName

class ClassName : TypeName, Comparable<ClassName>

A fully-qualified class name for top-level and member classes.

CodeBlock

class CodeBlock

A fragment of a .kt file, potentially containing declarations, statements, and documentation. Code blocks are not necessarily well-formed Kotlin code, and are not validated. This class assumes kotlinc will check correctness later!

Dynamic

object Dynamic : TypeName

FileSpec

class FileSpec

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

FunSpec

class FunSpec

A generated function declaration.

KModifier

enum class KModifier

LambdaTypeName

class LambdaTypeName : TypeName

NameAllocator

class NameAllocator

Assigns Kotlin identifier names to avoid collisions, keywords, and invalid characters. To use, first create an instance and allocate all of the names that you need. Typically this is a mix of user-supplied names and constants:

ParameterSpec

class ParameterSpec

A generated parameter declaration.

ParameterizedTypeName

class ParameterizedTypeName : TypeName

PropertySpec

class PropertySpec

A generated property declaration.

TypeAliasSpec

class TypeAliasSpec

A generated typealias declaration

TypeName

sealed class TypeName

Any type in Kotlin's type system. This class identifies simple types like Int and String, nullable types like Int?, composite types like Array<String> and Set<String>, and unassignable types like Unit.

TypeSpec

class TypeSpec

A generated class, interface, or enum declaration.

TypeVariableName

class TypeVariableName : TypeName

WildcardTypeName

class WildcardTypeName : TypeName

Extensions for External Classes

java.lang.Class

java.lang.reflect.ParameterizedType

java.lang.reflect.Type

java.lang.reflect.WildcardType

javax.lang.model.element.TypeElement

javax.lang.model.element.TypeParameterElement

javax.lang.model.type.TypeMirror

javax.lang.model.type.TypeVariable

javax.lang.model.type.WildcardType

kotlin.collections.Collection

kotlin.reflect.KClass

kotlin.reflect.KType

kotlin.reflect.KTypeParameter

Properties

ANY

val ANY: ClassName

ARRAY

val ARRAY: ClassName

BOOLEAN

val BOOLEAN: ClassName

BYTE

val BYTE: ClassName

CHAR

val CHAR: ClassName

DOUBLE

val DOUBLE: ClassName

DYNAMIC

val DYNAMIC: Dynamic

Dynamic is a singleton object type, so this is a shorthand for it in Java.

FLOAT

val FLOAT: ClassName

INT

val INT: ClassName

LONG

val LONG: ClassName

SHORT

val SHORT: ClassName

STAR

val STAR: WildcardTypeName

The wildcard type * which is shorthand for out Any?.

UNIT

val UNIT: ClassName

Functions

buildCodeBlock

fun buildCodeBlock(builderAction: Builder.() -> Unit): CodeBlock

Builds new CodeBlock by populating newly created CodeBlock.Builder using provided builderAction and then converting it to CodeBlock.