TypeParameterElement (Java SE 26 & JDK 26)
Description: declaration: module: java.compiler, package: javax.lang.model.element, interface: TypeParameterElement
Keywords: javax.lang.model.element.TypeParameterElement interface

# Interface TypeParameterElement

All Superinterfaces:
  `AnnotatedConstruct, Element`

public interface TypeParameterElement extends Element
Represents a formal type parameter of a generic class, interface, method, or constructor element. A type parameter declares a `TypeVariable`.

Since:
  1.6
See Also:
  - `TypeVariable`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `TypeMirror`
  `asType()`
  Returns the type variable corresponding to this type parameter element.
  `List<? extends TypeMirror>`
  `getBounds()`
  Returns the bounds of this type parameter.
  `Element`
  `getEnclosingElement()`
  Returns the generic element of this type parameter.
  `Element`
  `getGenericElement()`
  Returns the generic class, interface, method, or constructor that is parameterized by this type parameter.

  ### Methods declared in interface Element

  `accept, equals, getAnnotation, getAnnotationMirrors, getAnnotationsByType, getEnclosedElements, getKind, getModifiers, getSimpleName, hashCode`
  Modifier and Type
  Method
  Description
  `<R,P> R`
  `accept(ElementVisitor<R,P> v, P p)`
  Applies a visitor to this element.
  `boolean`
  `equals(Object obj)`
  Returns `true` if the argument represents the same element as `this`, or `false` otherwise.
  `<A extends Annotation>
  A`
  `getAnnotation(Class<A> annotationType)`
  Returns this construct's annotation of the specified type if such an annotation is present, else `null`.
  `List<? extends AnnotationMirror>`
  `getAnnotationMirrors()`
  Returns the annotations that are directly present on this construct.
  `<A extends Annotation>
  A[]`
  `getAnnotationsByType(Class<A> annotationType)`
  Returns annotations of the specified type that are associated with this construct.
  `List<? extends Element>`
  `getEnclosedElements()`
  Returns the elements that are, loosely speaking, directly enclosed by this element.
  `ElementKind`
  `getKind()`
  Returns the `kind` of this element.
  `Set<Modifier>`
  `getModifiers()`
  Returns the modifiers of this element, excluding annotations.
  `Name`
  `getSimpleName()`
  Returns the simple (unqualified) name of this element.
  `int`
  `hashCode()`
  Obeys the general contract of `Object.hashCode`.

- ## Method Details

  - ### asType

    TypeMirror asType()
    Returns the type variable corresponding to this type parameter element.
    Specified by:
      `asType` in interface `Element`
    Returns:
      the type variable corresponding to this type parameter element
    See Also:
      - `TypeVariable`

  - ### getGenericElement

    Element getGenericElement()
    Returns the generic class, interface, method, or constructor that is parameterized by this type parameter.
    Returns:
      the generic class, interface, method, or constructor that is parameterized by this type parameter

  - ### getBounds

    List<? extends TypeMirror> getBounds()
    Returns the bounds of this type parameter. These are the types given by the `extends` clause used to declare this type parameter. If no explicit `extends` clause was used, then `java.lang.Object` is considered to be the sole bound.
    Returns:
      the bounds of this type parameter, or an empty list if there are none

  - ### getEnclosingElement

    Element getEnclosingElement()
    Returns the generic element of this type parameter.
    Specified by:
      `getEnclosingElement` in interface `Element`
    Returns:
      the generic element of this type parameter
    See Also:
      - `Elements.getPackageOf(Element)`