interface KClass<T : Any> : KDeclarationContainer, KAnnotatedElement, KClassifier
Represents a class and provides introspection capabilities. Instances of this class are obtainable by the ::class
syntax. See the Kotlin language documentation for more information.
T
- the type of the class.
true
if this class is a companion object. See the Kotlin language documentation for more information.
true
if this class is a data class. See the Kotlin language documentation for more information.
true
if this class is an inner class. See the Kotlin language documentation for more information.
true
if this class is sealed
. See the Kotlin language documentation for more information.
Returns true
if value is an instance of this class on a given platform.
All superclasses of this class, including indirect ones, in no particular order. Includes superclasses and superinterfaces of the class, but does not include the class itself. The returned collection does not contain more than one instance of any given class.
Returns a KClass instance representing the companion object of a given class, or null
if the class doesn't have a companion object.
Returns a type corresponding to the given class with type parameters of that class substituted as the corresponding arguments. For example, for class MyMap<K, V>
defaultType would return the type MyMap<K, V>
.
Returns the JVM name of the class represented by this KClass instance.
Returns the primary constructor of this class, or null
if this class has no primary constructor. See the Kotlin language documentation for more information.
Creates an instance of KType with the given classifier, substituting all its type parameters with star projections. The resulting type is not marked as nullable and does not have any annotations.
Creates a new instance of the class, calling a constructor which either has no parameters or all parameters of which are optional (see KParameter.isOptional). If there are no or many such constructors, an exception is thrown.
Creates a KType instance with the given classifier, type arguments, nullability and annotations. If the number of passed type arguments is not equal to the total number of type parameters of a classifier, an exception is thrown. If any of the arguments does not satisfy the bounds of the corresponding type parameter, an exception is thrown.
Returns true if this element is annotated with an annotation of type T.
Returns true
if this
class is the same or is a (possibly indirect) subclass of base, false
otherwise.
Returns true
if this
class is the same or is a (possibly indirect) superclass of derived, false
otherwise.
© 2010–2020 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.reflect/-k-class/