Parameter
class Parameter : AnnotatedElement
kotlin.Any | |
↳ | java.lang.reflect.Parameter |
Information about method parameters. A Parameter
provides information about method parameters, including its name and modifiers. It also provides an alternate means of obtaining attributes for the parameter.
Summary
Public methods | |
---|---|
Boolean |
Compares based on the executable and the index. |
T? |
getAnnotation(annotationClass: Class<T>) Returns this element's annotation for the specified type if such an annotation is present, else null. |
Array<Annotation!> |
Returns annotations that are present on this element. |
Array<T>! |
getAnnotationsByType(annotationClass: Class<T>) Returns annotations that are associated with this element. |
T? |
getDeclaredAnnotation(annotationClass: Class<T>) |
Array<Annotation!> |
Returns annotations that are directly present on this element. |
Array<T>! |
getDeclaredAnnotationsByType(annotationClass: Class<T>) |
Executable |
Return the |
Int |
Get the modifier flags for this the parameter represented by this |
String |
getName() Returns the name of the parameter. |
Type |
Returns a |
Class<*> |
getType() Returns a |
Int |
hashCode() Returns a hash code based on the executable's hash code and the index. |
Boolean |
Returns |
Boolean |
Returns true if the parameter has a name; returns false otherwise. |
Boolean |
Returns |
Boolean |
Returns |
String |
toString() Returns a string describing this parameter. |
Inherited functions | |
---|---|
Public methods
equals
fun equals(other: Any?): Boolean
Compares based on the executable and the index.
Parameters | |
---|---|
obj |
The object to compare. |
Return | |
---|---|
Boolean |
Whether or not this is equal to the argument. |
getAnnotation
fun <T : Annotation!> getAnnotation(annotationClass: Class<T>): T?
Returns this element's annotation for the specified type if such an annotation is present, else null.
Parameters | |
---|---|
<T> |
the type of the annotation to query for and return if present |
annotationClass |
Class<T>: the Class object corresponding to the annotation type |
Return | |
---|---|
T? |
this element's annotation for the specified annotation type if present on this element, else null |
Exceptions | |
---|---|
java.lang.NullPointerException |
if the given annotation class is null |
getAnnotations
fun getAnnotations(): Array<Annotation!>
Returns annotations that are present on this element. If there are no annotations present on this element, the return value is an array of length 0. The caller of this method is free to modify the returned array; it will have no effect on the arrays returned to other callers.
Return | |
---|---|
Array<Annotation!> |
annotations present on this element |
getAnnotationsByType
fun <T : Annotation!> getAnnotationsByType(annotationClass: Class<T>): Array<T>!
Returns annotations that are associated with this element. If there are no annotations associated with this element, the return value is an array of length 0. The difference between this method and getAnnotation(java.lang.Class)
is that this method detects if its argument is a repeatable annotation type (JLS 9.6), and if so, attempts to find one or more annotations of that type by "looking through" a container annotation. The caller of this method is free to modify the returned array; it will have no effect on the arrays returned to other callers.
Parameters | |
---|---|
<T> |
the type of the annotation to query for and return if present |
annotationClass |
Class<T>: the Class object corresponding to the annotation type |
Return | |
---|---|
Array<T>! |
all this element's annotations for the specified annotation type if associated with this element, else an array of length zero |
Exceptions | |
---|---|
java.lang.NullPointerException |
if the given annotation class is null |
getDeclaredAnnotation
fun <T : Annotation!> getDeclaredAnnotation(annotationClass: Class<T>): T?
Parameters | |
---|---|
<T> |
the type of the annotation to query for and return if directly present |
annotationClass |
Class<T>: the Class object corresponding to the annotation type |
Return | |
---|---|
T? |
this element's annotation for the specified annotation type if directly present on this element, else null |
Exceptions | |
---|---|
java.lang.NullPointerException |
if the given annotation class is null |
getDeclaredAnnotations
fun getDeclaredAnnotations(): Array<Annotation!>
Returns annotations that are directly present on this element. This method ignores inherited annotations. If there are no annotations directly present on this element, the return value is an array of length 0. The caller of this method is free to modify the returned array; it will have no effect on the arrays returned to other callers.
Return | |
---|---|
Array<Annotation!> |
annotations directly present on this element |
getDeclaredAnnotationsByType
fun <T : Annotation!> getDeclaredAnnotationsByType(annotationClass: Class<T>): Array<T>!
Parameters | |
---|---|
<T> |
the type of the annotation to query for and return if directly or indirectly present |
annotationClass |
Class<T>: the Class object corresponding to the annotation type |
Return | |
---|---|
Array<T>! |
all this element's annotations for the specified annotation type if directly or indirectly present on this element, else an array of length zero |
Exceptions | |
---|---|
java.lang.NullPointerException |
if the given annotation class is null |
getDeclaringExecutable
fun getDeclaringExecutable(): Executable
Return the Executable
which declares this parameter.
Return | |
---|---|
Executable |
The Executable declaring this parameter. |
getModifiers
fun getModifiers(): Int
Get the modifier flags for this the parameter represented by this Parameter
object.
Return | |
---|---|
Int |
The modifier flags for this parameter. |
getName
fun getName(): String
Returns the name of the parameter. If the parameter's name is present, then this method returns the name provided by the class file. Otherwise, this method synthesizes a name of the form argN, where N is the index of the parameter in the descriptor of the method which declares the parameter.
Return | |
---|---|
String |
The name of the parameter, either provided by the class file or synthesized if the class file does not provide a name. |
getParameterizedType
fun getParameterizedType(): Type
Returns a Type
object that identifies the parameterized type for the parameter represented by this Parameter
object.
Return | |
---|---|
Type |
a Type object identifying the parameterized type of the parameter represented by this object |
getType
fun getType(): Class<*>
Returns a Class
object that identifies the declared type for the parameter represented by this Parameter
object.
Return | |
---|---|
Class<*> |
a Class object identifying the declared type of the parameter represented by this object |
hashCode
fun hashCode(): Int
Returns a hash code based on the executable's hash code and the index.
Return | |
---|---|
Int |
A hash code based on the executable's hash code. |
isImplicit
fun isImplicit(): Boolean
Returns true
if this parameter is implicitly declared in source code; returns false
otherwise.
Return | |
---|---|
Boolean |
true if and only if this parameter is implicitly declared as defined by The Java™ Language Specification. |
isNamePresent
fun isNamePresent(): Boolean
Returns true if the parameter has a name; returns false otherwise. Whether a parameter has a name is determined by compiler options and whether the parameter is synthesized.
Return | |
---|---|
Boolean |
true if and only if the parameter has a name |
isSynthetic
fun isSynthetic(): Boolean
Returns true
if this parameter is neither implicitly nor explicitly declared in source code; returns false
otherwise.
Return | |
---|---|
Boolean |
true if and only if this parameter is a synthetic construct as defined by The Java™ Language Specification. |
isVarArgs
fun isVarArgs(): Boolean
Returns true
if this parameter represents a variable argument list; returns false
otherwise.
Return | |
---|---|
Boolean |
true if an only if this parameter represents a variable argument list. |
toString
fun toString(): String
Returns a string describing this parameter. The format is the modifiers for the parameter, if any, in canonical order as recommended by The Java™ Language Specification, followed by the fully- qualified type of the parameter (excluding the last [] if the parameter is variable arity), followed by "..." if the parameter is variable arity, followed by a space, followed by the name of the parameter.
Return | |
---|---|
String |
A string representation of the parameter and associated information. |