# GenericDeclaration

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# GenericDeclaration

```
interface GenericDeclaration : AnnotatedElement
```

|------------------------------------------------------------------------------------------------------------------------------|
| [java.lang.reflect.GenericDeclaration](https://developer.android.com/reference/kotlin/java/lang/reflect/GenericDeclaration#) |

|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Known Direct Subclasses [Class](https://developer.android.com/reference/kotlin/java/lang/Class.html#),[Executable](https://developer.android.com/reference/kotlin/java/lang/reflect/Executable) |-------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Class](https://developer.android.com/reference/kotlin/java/lang/Class.html#)             | Instances of the class represent classes and interfaces in a running Java application.                                                                                                                                              | | [Executable](https://developer.android.com/reference/kotlin/java/lang/reflect/Executable) | A shared superclass for the common functionality of[Method](https://developer.android.com/reference/kotlin/java/lang/reflect/Method)and[Constructor](https://developer.android.com/reference/kotlin/java/lang/reflect/Constructor). | |

|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Known Indirect Subclasses [Constructor](https://developer.android.com/reference/kotlin/java/lang/reflect/Constructor),[Method](https://developer.android.com/reference/kotlin/java/lang/reflect/Method) |---------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------| | [Constructor](https://developer.android.com/reference/kotlin/java/lang/reflect/Constructor) | `Constructor`provides information about, and access to, a single constructor for a class.    | | [Method](https://developer.android.com/reference/kotlin/java/lang/reflect/Method)           | A`Method`provides information about, and access to, a single method on a class or interface. | |

A common interface for all entities that declare type variables.

## Summary

|                                                                                                                                                                                                                                                    Public methods                                                                                                                                                                                                                                                    ||
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| abstract[Array](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)\<[TypeVariable](https://developer.android.com/reference/kotlin/java/lang/reflect/TypeVariable)\<\*\>!\> | [getTypeParameters](https://developer.android.com/reference/kotlin/java/lang/reflect/GenericDeclaration#getTypeParameters())`()` Returns an array of`TypeVariable`objects that represent the type variables declared by the generic declaration represented by this`GenericDeclaration`object, in declaration order. |

| Inherited functions ||
|---|---|
| From class[AnnotatedElement](https://developer.android.com/reference/kotlin/java/lang/reflect/AnnotatedElement) |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | T?                                                                                                                                                                        | [getAnnotation](https://developer.android.com/reference/kotlin/java/lang/reflect/AnnotatedElement#getAnnotation(java.lang.Class))`(`annotationClass:` `[Class](https://developer.android.com/reference/kotlin/java/lang/Class.html#)<T>`)` <br /> Returns this element's annotation for the specified type if such an annotation is*present*, else null. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | | [Array](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)<[Annotation](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-annotation/index.html)!> | [getAnnotations](https://developer.android.com/reference/kotlin/java/lang/reflect/AnnotatedElement#getAnnotations())`()` <br /> 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. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | | [Array](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)<T>!                                                                                        | [getAnnotationsByType](https://developer.android.com/reference/kotlin/java/lang/reflect/AnnotatedElement#getAnnotationsByType(java.lang.Class))`(`annotationClass:` `[Class](https://developer.android.com/reference/kotlin/java/lang/Class.html#)<T>`)` <br /> 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)](https://developer.android.com/reference/kotlin/java/lang/reflect/AnnotatedElement#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. <br />                                                                                                                                                                                                   | | T?                                                                                                                                                                        | [getDeclaredAnnotation](https://developer.android.com/reference/kotlin/java/lang/reflect/AnnotatedElement#getDeclaredAnnotation(java.lang.Class))`(`annotationClass:` `[Class](https://developer.android.com/reference/kotlin/java/lang/Class.html#)<T>`)` <br /> Returns this element's annotation for the specified type if such an annotation is*directly present*, else null. This method ignores inherited annotations. (Returns null if no annotations are directly present on this element.) <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             | | [Array](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)<[Annotation](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-annotation/index.html)!> | [getDeclaredAnnotations](https://developer.android.com/reference/kotlin/java/lang/reflect/AnnotatedElement#getDeclaredAnnotations())`()` <br /> 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. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | | [Array](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)<T>!                                                                                        | [getDeclaredAnnotationsByType](https://developer.android.com/reference/kotlin/java/lang/reflect/AnnotatedElement#getDeclaredAnnotationsByType(java.lang.Class))`(`annotationClass:` `[Class](https://developer.android.com/reference/kotlin/java/lang/Class.html#)<T>`)` <br /> Returns this element's annotation(s) for the specified type if such annotations are either*directly present* or*indirectly present* . This method ignores inherited annotations. If there are no specified annotations directly or indirectly present on this element, the return value is an array of length 0. The difference between this method and[getDeclaredAnnotation(java.lang.Class)](https://developer.android.com/reference/kotlin/java/lang/reflect/AnnotatedElement#getDeclaredAnnotation(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 if one is present. The caller of this method is free to modify the returned array; it will have no effect on the arrays returned to other callers. <br /> | | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)                                                                                        | [isAnnotationPresent](https://developer.android.com/reference/kotlin/java/lang/reflect/AnnotatedElement#isAnnotationPresent(java.lang.Class))`(`annotationClass:` `[Class](https://developer.android.com/reference/kotlin/java/lang/Class.html#)<out` `[Annotation](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-annotation/index.html)!>`)` <br /> Returns true if an annotation for the specified type is*present*on this element, else false. This method is designed primarily for convenient access to marker annotations. The truth value returned by this method is equivalent to:`getAnnotation(annotationClass) != null` The body of the default method is specified to be the code above. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                     | ||

## Public methods

### getTypeParameters

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
abstract fun getTypeParameters(): Array<TypeVariable<*>!>
```

Returns an array of`TypeVariable`objects that represent the type variables declared by the generic declaration represented by this`GenericDeclaration`object, in declaration order. Returns an array of length 0 if the underlying generic declaration declares no type variables.

|                                                                                                                                           Return                                                                                                                                           ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------|
| [Array](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)<[TypeVariable](https://developer.android.com/reference/kotlin/java/lang/reflect/TypeVariable)<*>!> | an array of`TypeVariable`objects that represent the type variables declared by this generic declaration |

|                                                                                        Exceptions                                                                                         ||
|-------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------|
| `java.lang.reflect.GenericSignatureFormatError` | if the generic signature of this generic declaration does not conform to the format specified in The Java™ Virtual Machine Specification |