ClassName

class ClassName : TypeName, Comparable<ClassName>

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

Constructors

ClassName
Link copied to clipboard
fun ClassName(packageName: String, vararg simpleNames: String)
Returns a class name created from the given parts.
ClassName
Link copied to clipboard
fun ClassName(packageName: String, simpleNames: List<String>)
Returns a class name created from the given parts.

Types

Companion
Link copied to clipboard
object Companion

Functions

compareTo
Link copied to clipboard
open operator override fun compareTo(other: ClassName): Int
Orders by the fully-qualified name.
constructorReference
Link copied to clipboard
fun constructorReference(): CodeBlock
Callable reference to the constructor of this class.
copy
Link copied to clipboard
fun copy(nullable: Boolean = this.isNullable, annotations: List<AnnotationSpec> = this.annotations.toList()): TypeName
open override fun copy(nullable: Boolean, annotations: List<AnnotationSpec>, tags: Map<KClass<*>, Any>): ClassName
enclosingClassName
Link copied to clipboard
fun enclosingClassName(): ClassName?
Returns the enclosing class, like Map for Map.Entry.
equals
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
hashCode
Link copied to clipboard
open override fun hashCode(): Int
nestedClass
Link copied to clipboard
fun nestedClass(name: String): ClassName
Returns a new ClassName instance for the specified name as nested inside this class.
peerClass
Link copied to clipboard
fun peerClass(name: String): ClassName
Returns a class that shares the same enclosing package or class.
reflectionName
Link copied to clipboard
fun reflectionName(): String
Fully qualified name using . to separate package from the top level class name, and $ to separate nested classes, like kotlin.collections.Map$Entry.
tag
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.
topLevelClassName
Link copied to clipboard
fun topLevelClassName(): ClassName
Returns the top class in this nesting group.
toString
Link copied to clipboard
open override fun toString(): String

Properties

annotations
Link copied to clipboard
val annotations: List<AnnotationSpec>
canonicalName
Link copied to clipboard
val canonicalName: String
Fully qualified name using . as a separator, like kotlin.collections.Map.Entry.
isAnnotated
Link copied to clipboard
val isAnnotated: Boolean
isNullable
Link copied to clipboard
val isNullable: Boolean
packageName
Link copied to clipboard
val packageName: String
Package name, like "kotlin.collections" for Map.Entry.
simpleName
Link copied to clipboard
val simpleName: String
Simple name of this class, like "Entry" for Map.Entry.
simpleNames
Link copied to clipboard
val simpleNames: List<String>
The enclosing classes, outermost first, followed by the simple name.
tags
Link copied to clipboard
open override val tags: Map<KClass<*>, Any>
Returns all tags.

Extensions

member
Link copied to clipboard
inline fun ClassName.member(simpleName: String): MemberName
parameterizedBy
Link copied to clipboard
@JvmName(name = "get")
fun ClassName.parameterizedBy(vararg typeArguments: TypeName): ParameterizedTypeName
Returns a parameterized type, applying typeArguments to this.
@JvmName(name = "get")
fun ClassName.parameterizedBy(typeArguments: List<TypeName>): ParameterizedTypeName
Returns a parameterized type, applying typeArguments to this.
plusParameter
Link copied to clipboard
@JvmName(name = "get")
fun ClassName.plusParameter(typeArgument: TypeName): ParameterizedTypeName
Returns a parameterized type, applying typeArgument to this.