Package-level declarations

Types

Link copied to clipboard

A generated annotation on a declaration.

Link copied to clipboard

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

Link copied to clipboard
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!

Link copied to clipboard

A KotlinPoet spec type that can have a context receiver.

Link copied to clipboard
annotation class DelicateKotlinPoetApi(val message: String)

Marks declarations in the KotlinPoet API that are delicate — they have limited use-case and shall be used with care in general code. Any use of a delicate declaration has to be carefully reviewed to make sure it is properly used and does not create problems like lossy Java -> Kotlin type parsing. Carefully read documentation and message of any declaration marked as DelicateKotlinPoetApi.

Link copied to clipboard
object Dynamic : TypeName
Link copied to clipboard

Indicates that a given API is experimental and subject to change.

Link copied to clipboard

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

Link copied to clipboard

A generated function declaration.

Link copied to clipboard
data class Import : Comparable<Import>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
data class MemberName

Represents the name of a member (such as a function or a property).

Link copied to clipboard

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:

Link copied to clipboard

A type that can have originating elements.

Link copied to clipboard
Link copied to clipboard

A generated parameter declaration.

Link copied to clipboard

A generated property declaration.

Link copied to clipboard
interface Taggable

A type that can be tagged with extra metadata of the user's choice.

Link copied to clipboard

A generated typealias declaration

Link copied to clipboard
sealed class TypeName : Taggable

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.

Link copied to clipboard

A generated class, interface, or enum declaration.

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
@DelicateKotlinPoetApi(message = "Java reflection APIs don't give complete information on Kotlin types. Consider using the kotlinpoet-metadata APIs instead.")
@JvmName(name = "get")
fun Class<*>.asClassName(): ClassName
@JvmName(name = "get")
fun KClass<*>.asClassName(): ClassName

@DelicateKotlinPoetApi(message = "Element APIs don't give complete information on Kotlin types. Consider using the kotlinpoet-metadata APIs instead.")
@JvmName(name = "get")
fun TypeElement.asClassName(): ClassName

Returns the class name for element.

Link copied to clipboard
@DelicateKotlinPoetApi(message = "Java reflection APIs don't give complete information on Kotlin types. Consider using the kotlinpoet-metadata APIs instead.")
@JvmName(name = "get")
fun ParameterizedType.asParameterizedTypeName(): ParameterizedTypeName

Returns a parameterized type equivalent to type.

Link copied to clipboard
@JvmName(name = "get")
fun Type.asTypeName(): TypeName

Returns a TypeName equivalent to this Type.

@DelicateKotlinPoetApi(message = "Mirror APIs don't give complete information on Kotlin types. Consider using the kotlinpoet-metadata APIs instead.")
@JvmName(name = "get")
fun TypeMirror.asTypeName(): TypeName

Returns a TypeName equivalent to this TypeMirror.

@JvmName(name = "get")
fun KClass<*>.asTypeName(): ClassName

Returns a TypeName equivalent to this KClass.

Returns a TypeName equivalent to the given Kotlin KType using reflection, maybe using kotlin-reflect if required.

Link copied to clipboard
@DelicateKotlinPoetApi(message = "Element APIs don't give complete information on Kotlin types. Consider using the kotlinpoet-metadata APIs instead.")
@JvmName(name = "get")
fun TypeParameterElement.asTypeVariableName(): TypeVariableName

Returns type variable equivalent to element.

@DelicateKotlinPoetApi(message = "Java reflection APIs don't give complete information on Kotlin types. Consider using the kotlinpoet-metadata APIs instead.")
@JvmName(name = "get")
fun TypeVariable.asTypeVariableName(): TypeVariableName

Returns type variable equivalent to mirror.

Link copied to clipboard
@DelicateKotlinPoetApi(message = "Java reflection APIs don't give complete information on Kotlin types. Consider using the kotlinpoet-metadata APIs instead.")
@JvmName(name = "get")
fun WildcardType.asWildcardTypeName(): TypeName
@DelicateKotlinPoetApi(message = "Mirror APIs don't give complete information on Kotlin types. Consider using the kotlinpoet-metadata APIs instead.")
@JvmName(name = "get")
fun WildcardType.asWildcardTypeName(): TypeName
Link copied to clipboard
inline fun buildCodeBlock(builderAction: CodeBlock.Builder.() -> Unit): CodeBlock

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

Link copied to clipboard
fun Collection<CodeBlock>.joinToCode(separator: CharSequence = ", ", prefix: CharSequence = "", suffix: CharSequence = ""): CodeBlock
Link copied to clipboard
inline 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.

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

Link copied to clipboard
inline fun <T> typeNameOf(): TypeName

Returns a TypeName equivalent of the reified type parameter T using reflection, maybe using kotlin-reflect if required.

Link copied to clipboard

Calls CodeBlock.Builder.indent then executes the provided builderAction on the CodeBlock.Builder and then executes CodeBlock.Builder.unindent before returning the original CodeBlock.Builder.

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

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

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

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

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard