TypeName

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.

Type names are dumb identifiers only and do not model the values they name. For example, the type name for kotlin.List doesn't know about the size() function, the fact that lists are collections, or even that it accepts a single type parameter.

Instances of this class are immutable value objects that implement equals() and hashCode() properly.

Referencing existing types

--------------------------

In an annotation processor you can get a type name instance for a type mirror by calling asTypeName. In reflection code, you can use asTypeName.

Defining new types

------------------

Create new reference types like com.example.HelloWorld with ClassName.bestGuess. To build composite types like Set<Long>, use the factory methods on ParameterizedTypeName, TypeVariableName, and WildcardTypeName.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun copy(nullable: Boolean = this.isNullable, annotations: List<AnnotationSpec> = this.annotations.toList()): TypeName
abstract fun copy(    nullable: Boolean = this.isNullable,     annotations: List<AnnotationSpec> = this.annotations.toList(),     tags: Map<KClass<*>, Any> = this.tags): TypeName
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun <T : Any> tag(type: Class<T>): T?

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

open override fun <T : Any> tag(type: KClass<T>): T?

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

Link copied to clipboard
open override fun toString(): String

Properties

Link copied to clipboard
val annotations: List<AnnotationSpec>
Link copied to clipboard
val isAnnotated: Boolean
Link copied to clipboard
val isNullable: Boolean
Link copied to clipboard
open override val tags: Map<KClass<*>, Any>

Returns all tags.

Inheritors

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

Extensions

Link copied to clipboard
fun TypeName.jvmSuppressWildcards(suppress: Boolean = true): TypeName
Link copied to clipboard
fun TypeName.jvmWildcard(): TypeName