ClassName

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

Constructors

Link copied to clipboard
constructor(packageName: String, vararg simpleNames: String)

Returns a class name created from the given parts. For example, calling this with package name "java.util" and simple names "Map", "Entry" yields Map.Entry.

constructor(packageName: String, simpleNames: List<String>)

Returns a class name created from the given parts. For example, calling this with package name "java.util" and simple names "Map", "Entry" yields Map.Entry.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override val annotations: List<AnnotationSpec>
Link copied to clipboard

Fully qualified name using . as a separator, like kotlin.collections.Map.Entry.

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

Package name, like "kotlin.collections" for Map.Entry.

Link copied to clipboard

Simple name of this class, like "Entry" for Map.Entry.

Link copied to clipboard

The enclosing classes, outermost first, followed by the simple name. This is ["Map", "Entry"] for Map.Entry.

Link copied to clipboard
open override val tags: Map<KClass<*>, Any>

Returns all tags.

Functions

Link copied to clipboard
open operator override fun compareTo(other: ClassName): Int

Orders by the fully-qualified name. Nested types are ordered immediately after their enclosing type. For example, the following types are ordered by this method:

Link copied to clipboard

Callable reference to the constructor of this class. Emits the enclosing class if one exists, followed by the reference operator ::, followed by either simpleName or the fully-qualified name if this is a top-level class.

Link copied to clipboard
open override fun copy(nullable: Boolean, annotations: List<AnnotationSpec>, tags: Map<KClass<*>, Any>): ClassName
fun copy(nullable: Boolean = this.isNullable, annotations: List<AnnotationSpec> = this.annotations.toList()): TypeName
Link copied to clipboard

Returns the enclosing class, like Map for Map.Entry. Returns null if this class is not nested in another class.

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
Link copied to clipboard
Link copied to clipboard
inline fun ClassName.member(simpleName: String): MemberName
Link copied to clipboard

Returns a new ClassName instance for the specified name as nested inside this class.

Link copied to clipboard

Returns a parameterized type, applying typeArguments to this.

Link copied to clipboard

Returns a class that shares the same enclosing package or class. If this class is enclosed by another class, this is equivalent to enclosingClassName().nestedClass(name). Otherwise it is equivalent to get(packageName(), name).

Link copied to clipboard

Returns a parameterized type, applying typeArgument to this.

Link copied to clipboard

Fully qualified name using . to separate package from the top level class name, and $ to separate nested classes, like kotlin.collections.Map$Entry.

Link copied to clipboard
open override fun <T : Any> tag(type: <Error class: unknown 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
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.

Link copied to clipboard

Returns the top class in this nesting group. Equivalent to chained calls to ClassName.enclosingClassName until the result's enclosing class is null.

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