Platform and version requirements: Kotlin 1.1, JVM
Extensions for Kotlin reflection provided by kotlin-reflect
library.
class IllegalCallableAccessException : IllegalCallableAccessException An exception that is thrown when | |
class IllegalPropertyDelegateAccessException An exception that is thrown when | |
class NoSuchPropertyException : NoSuchPropertyException An exception that is thrown when the code tries to introspect a property of a class or a package and that class or the package no longer has that property. |
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 KCallable<*>.extensionReceiverParameter: KParameter? Returns a parameter representing the extension receiver instance needed to call this callable, or | |
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 KCallable<*>.instanceParameter: KParameter? Returns a parameter representing the | |
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. | |
val KCallable<*>.valueParameters: List<KParameter> Returns parameters of this callable, excluding the |
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 KCallable<*>.findParameterByName( name: String ): KParameter? Returns the parameter of this callable with the given name, or | |
fun KProperty1<*, *>.getExtensionDelegate(): Any? Returns the instance of a delegated extension property, or fun <D> KProperty2<D, *, *>.getExtensionDelegate( receiver: D ): Any? Returns the instance of a delegated member extension property, or | |
fun KClass<*>.isSubclassOf(base: KClass<*>): Boolean Returns | |
fun KType.isSubtypeOf(other: KType): Boolean Returns | |
fun KClass<*>.isSuperclassOf(derived: KClass<*>): Boolean Returns | |
fun KType.isSupertypeOf(other: KType): Boolean Returns | |
fun <T : Any> KClass<T>.safeCast(value: Any?): T? Casts the given value to the class represented by this KClass object. Returns | |
fun KType.withNullability(nullable: Boolean): KType Returns a new type with the same classifier, arguments and annotations as the given type, and with the given nullability. |
© 2010–2017 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.reflect.full/