Skip to content

API

kotlinpoet / com.squareup.kotlinpoet

Package com.squareup.kotlinpoet

Types

Name Summary
AnnotationSpec class AnnotationSpec :Taggable
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 :Taggable
A Kotlin file containing top level objects like classes, objects, functions, properties, and type aliases.
FunSpec class FunSpec :Taggable,OriginatingElementsHolder
A generated function declaration.
KModifier enum class KModifier
LambdaTypeName class LambdaTypeName :TypeName
MemberName data class MemberName
Represents the name of a member (such as a function or a property).
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:
OriginatingElementsHolder interface OriginatingElementsHolder
A type that can have originating elements.
ParameterizedTypeName class ParameterizedTypeName :TypeName
ParameterSpec class ParameterSpec :Taggable
A generated parameter declaration.
PropertySpec class PropertySpec :Taggable,OriginatingElementsHolder
A generated property declaration.
Taggable interface Taggable
A type that can be tagged with extra metadata of the user’s choice.
TypeAliasSpec class TypeAliasSpec :Taggable
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 :Taggable,OriginatingElementsHolder
A generated class, interface, or enum declaration.
TypeVariableName class TypeVariableName :TypeName
WildcardTypeName class WildcardTypeName :TypeName

Extensions for External Classes

Name Summary
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

Name Summary
ANNOTATION val ANNOTATION:ClassName
ANY val ANY:ClassName
ARRAY val ARRAY:ClassName
BOOLEAN val BOOLEAN:ClassName
BOOLEAN_ARRAY val BOOLEAN_ARRAY:ClassName
BYTE val BYTE:ClassName
BYTE_ARRAY val BYTE_ARRAY:ClassName
CHAR val CHAR:ClassName
CHAR_ARRAY val CHAR_ARRAY:ClassName
CHAR_SEQUENCE val CHAR_SEQUENCE:ClassName
COLLECTION val COLLECTION:ClassName
COMPARABLE val COMPARABLE:ClassName
DOUBLE val DOUBLE:ClassName
DOUBLE_ARRAY val DOUBLE_ARRAY:ClassName
DYNAMIC val DYNAMIC:Dynamic
Dynamic is a singleton object type, so this is a shorthand for it in Java.
ENUM val ENUM:ClassName
FLOAT val FLOAT:ClassName
FLOAT_ARRAY val FLOAT_ARRAY:ClassName
INT val INT:ClassName
INT_ARRAY val INT_ARRAY:ClassName
ITERABLE val ITERABLE:ClassName
LIST val LIST:ClassName
LONG val LONG:ClassName
LONG_ARRAY val LONG_ARRAY:ClassName
MAP val MAP:ClassName
MAP_ENTRY val MAP_ENTRY:ClassName
MUTABLE_COLLECTION val MUTABLE_COLLECTION:ClassName
MUTABLE_ITERABLE val MUTABLE_ITERABLE:ClassName
MUTABLE_LIST val MUTABLE_LIST:ClassName
MUTABLE_MAP val MUTABLE_MAP:ClassName
MUTABLE_MAP_ENTRY val MUTABLE_MAP_ENTRY:ClassName
MUTABLE_SET val MUTABLE_SET:ClassName
NOTHING val NOTHING:ClassName
NUMBER val NUMBER:ClassName
SET val SET:ClassName
SHORT val SHORT:ClassName
SHORT_ARRAY val SHORT_ARRAY:ClassName
STAR val STAR:WildcardTypeName
The wildcard type * which is shorthand for out Any?.
STRING val STRING:ClassName
THROWABLE val THROWABLE:ClassName
U_BYTE val U_BYTE:ClassName
U_BYTE_ARRAY val U_BYTE_ARRAY:ClassName
U_INT val U_INT:ClassName
U_INT_ARRAY val U_INT_ARRAY:ClassName
U_LONG val U_LONG:ClassName
U_LONG_ARRAY val U_LONG_ARRAY:ClassName
U_SHORT val U_SHORT:ClassName
U_SHORT_ARRAY val U_SHORT_ARRAY:ClassName
UNIT val UNIT:ClassName

Functions

Name Summary
buildCodeBlock 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.
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.fun <T :Any>AnnotationSpec.Builder.tag(tag:T?):AnnotationSpec.Builder
fun <T :Any>FileSpec.Builder.tag(tag:T?):FileSpec.Builder
fun <T :Any>FunSpec.Builder.tag(tag:T?):FunSpec.Builder
fun <T :Any>ParameterSpec.Builder.tag(tag:T?):ParameterSpec.Builder
fun <T :Any>PropertySpec.Builder.tag(tag:T?):PropertySpec.Builder
fun <T :Any>TypeAliasSpec.Builder.tag(tag:T?):TypeAliasSpec.Builder
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.