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.
abstract val constructors: Collection<KFunction<T>> All constructors declared in this class. | |
abstract val isAbstract: Boolean
| |
abstract val isCompanion: Boolean
| |
abstract val isData: Boolean
| |
abstract val isFinal: Boolean
| |
abstract val isInner: Boolean
| |
abstract val isOpen: Boolean
| |
abstract val isSealed: Boolean
| |
abstract val members: Collection<KCallable<*>> All functions and properties accessible in this class, including those declared in this class and all of its superclasses. Does not include constructors. | |
abstract val nestedClasses: Collection<KClass<*>> All classes declared inside this class. This includes both inner and static nested classes. | |
abstract val objectInstance: T? The instance of the object declaration, or | |
abstract val qualifiedName: String? The fully qualified dot-separated name of the class, or | |
abstract val simpleName: String? The simple name of the class as it was declared in the source code, or | |
abstract val supertypes: List<KType> The list of immediate supertypes of this class, in the order they are listed in the source code. | |
abstract val typeParameters: List<KTypeParameter> The list of type parameters of this class. This list does not include type parameters of outer classes. | |
abstract val visibility: KVisibility? Visibility of this class, or |
abstract val annotations: List<Annotation> Annotations which are present on this element. |
abstract fun equals(other: Any?): Boolean Returns | |
abstract fun hashCode(): Int Returns a hash code value for the object. The general contract of hashCode is: | |
abstract fun isInstance(value: Any?): Boolean Returns |
val KClass<*>.allSuperclasses: Collection<KClass<*>> 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. | |
val KClass<*>.allSupertypes: Collection<KType> All supertypes of this class, including indirect ones, in no particular order. There is not more than one type in the returned collection that has any given classifier. | |
val KClass<*>.companionObject: KClass<*>? Returns a KClass instance representing the companion object of a given class, or | |
val KClass<*>.companionObjectInstance: Any? Returns an instance of the companion object of a given class, or | |
val KClass<*>.declaredFunctions: Collection<KFunction<*>> Returns all functions declared in this class. If this is a Java class, it includes all non-static methods (both extensions and non-extensions) declared in the class and the superclasses, as well as static methods declared in the class. | |
val KClass<*>.declaredMemberExtensionFunctions: Collection<KFunction<*>> Returns extension functions declared in this class. | |
val <T : Any> KClass<T>.declaredMemberExtensionProperties: Collection<KProperty2<T, *, *>> Returns extension properties declared in this class. | |
val KClass<*>.declaredMemberFunctions: Collection<KFunction<*>> Returns non-extension non-static functions declared in this class. | |
val <T : Any> KClass<T>.declaredMemberProperties: Collection<KProperty1<T, *>> Returns non-extension properties declared in this class. | |
val KClass<*>.declaredMembers: Collection<KCallable<*>> Returns all functions and properties declared in this class. Does not include members declared in supertypes. | |
val KClass<*>.defaultType: KType Returns a type corresponding to the given class with type parameters of that class substituted as the corresponding arguments. For example, for class | |
val KClass<*>.functions: Collection<KFunction<*>> Returns all functions declared in this class, including all non-static methods declared in the class and the superclasses, as well as static methods declared in the class. | |
val <T> KClass<T>.java: Class<T> Returns a Java Class instance corresponding to the given KClass instance. | |
val <T : Any> KClass<T>.javaClass: Class<KClass<T>> | |
val <T : Any> KClass<T>.javaObjectType: Class<T> Returns a Java Class instance corresponding to the given KClass instance. In case of primitive types it returns corresponding wrapper classes. | |
val <T : Any> KClass<T>.javaPrimitiveType: Class<T>? Returns a Java Class instance representing the primitive type corresponding to the given KClass if it exists. | |
val <T : Any> KClass<T>.js: JsClass<T> Obtains a constructor reference for the given | |
val KClass<*>.jvmName: String Returns the JVM name of the class represented by this KClass instance. | |
val KClass<*>.memberExtensionFunctions: Collection<KFunction<*>> Returns extension functions declared in this class and all of its superclasses. | |
val <T : Any> KClass<T>.memberExtensionProperties: Collection<KProperty2<T, *, *>> Returns extension properties declared in this class and all of its superclasses. | |
val KClass<*>.memberFunctions: Collection<KFunction<*>> Returns non-extension non-static functions declared in this class and all of its superclasses. | |
val <T : Any> KClass<T>.memberProperties: Collection<KProperty1<T, *>> Returns non-extension properties declared in this class and all of its superclasses. | |
val <T : Any> KClass<T>.primaryConstructor: KFunction<T>? Returns the primary constructor of this class, or | |
val KClassifier.starProjectedType: KType 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. | |
val KClass<*>.staticFunctions: Collection<KFunction<*>> Returns static functions declared in this class. | |
val KClass<*>.staticProperties: Collection<KProperty0<*>> Returns static properties declared in this class. Only properties representing static fields of Java classes are considered static. | |
val KClass<*>.superclasses: List<KClass<*>> Immediate superclasses of this class, in the order they are listed in the source code. Includes superclasses and superinterfaces of the class, but does not include the class itself. |
fun <T : Any> KClass<T>.cast(value: Any?): T Casts the given value to the class represented by this KClass object. Throws an exception if the value is | |
fun <T : Any> KClass<T>.createInstance(): T 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. | |
fun KClassifier.createType( arguments: List<KTypeProjection> = emptyList(), nullable: Boolean = false, annotations: List<Annotation> = emptyList() ): KType 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. | |
fun <T : Annotation> KAnnotatedElement.findAnnotation(): T? Returns an annotation of the given type on this element. | |
fun KClass<*>.isSubclassOf(base: KClass<*>): Boolean Returns | |
fun KClass<*>.isSuperclassOf(derived: KClass<*>): Boolean Returns | |
fun <T : Any> KClass<T>.safeCast(value: Any?): T? Casts the given value to the class represented by this KClass object. Returns |
© 2010–2018 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.reflect/-k-class/index.html