W3cubDocs

/Kotlin

KParameter

Platform and version requirements: JVM (1.0), JS (1.1)
interface KParameter : KAnnotatedElement

Represents a parameter passed to a function or a property getter/setter, including this and extension receiver parameters.

Types

Platform and version requirements: JVM (1.0), JS (1.0)

Kind

Kind represents a particular position of the parameter declaration in the source code, such as an instance, an extension receiver parameter or a value parameter.

enum class Kind

Properties

Platform and version requirements: JVM (1.0), JS (1.0)

index

0-based index of this parameter in the parameter list of its containing callable.

abstract val index: Int
Platform and version requirements: JVM (1.0), JS (1.0)

isOptional

true if this parameter is optional and can be omitted when making a call via KCallable.callBy, or false otherwise.

abstract val isOptional: Boolean
Platform and version requirements: JVM (1.1), JS (1.1)

isVararg

true if this parameter is vararg. See the Kotlin language documentation for more information.

abstract val isVararg: Boolean
Platform and version requirements: JVM (1.0), JS (1.0)

kind

Kind of this parameter.

abstract val kind: Kind
Platform and version requirements: JVM (1.0), JS (1.0)

name

Name of this parameter as it was declared in the source code, or null if the parameter has no name or its name is not available at runtime. Examples of nameless parameters include this instance for member functions, extension receiver for extension functions or properties, parameters of Java methods compiled without the debug information, and others.

abstract val name: String?
Platform and version requirements: JVM (1.0), JS (1.0)

type

Type of this parameter. For a vararg parameter, this is the type of the corresponding array, not the individual element.

abstract val type: KType

Extension Functions

Platform and version requirements: JVM (1.1)

findAnnotation

Returns an annotation of the given type on this element.

fun <T : Annotation> KAnnotatedElement.findAnnotation(): T?
Platform and version requirements: JVM (1.3)

hasAnnotation

Returns true if this element is annotated with an annotation of type T.

fun <T : Annotation> KAnnotatedElement.hasAnnotation(): Boolean

© 2010–2019 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.reflect/-k-parameter/index.html