-
- All Superinterfaces:
- Element, Parameterizable, QualifiedNameable
public interface TypeElement extends Element, Parameterizable, QualifiedNameable
Represents a class or interface program element. Provides access to information about the type and its members. Note that an enum type is a kind of class and an annotation type is a kind of interface.While a
TypeElement
represents a class or interface element, aDeclaredType
represents a class or interface type, the latter being a use (or invocation) of the former. The distinction is most apparent with generic types, for which a single element can define a whole family of types. For example, the elementjava.util.Set
corresponds to the parameterized typesjava.util.Set<String>
andjava.util.Set<Number>
(and many others), and to the raw typejava.util.Set
.Each method of this interface that returns a list of elements will return them in the order that is natural for the underlying source of program information. For example, if the underlying source of information is Java source code, then the elements will be returned in source code order.
- Since:
- 1.6
- See Also:
DeclaredType
-
-
Method Summary
Methods Modifier and Type Method and Description List<? extends Element>
getEnclosedElements()
Returns the elements that are, loosely speaking, directly enclosed by this element.Element
getEnclosingElement()
Returns the package of a top-level type and returns the immediately lexically enclosing element for a nested type.List<? extends TypeMirror>
getInterfaces()
Returns the interface types directly implemented by this class or extended by this interface.NestingKind
getNestingKind()
Returns the nesting kind of this type element.Name
getQualifiedName()
Returns the fully qualified name of this type element.Name
getSimpleName()
Returns the simple name of this type element.TypeMirror
getSuperclass()
Returns the direct superclass of this type element.List<? extends TypeParameterElement>
getTypeParameters()
Returns the formal type parameters of this type element in declaration order.-
Methods inherited from interface javax.lang.model.element.Element
accept, asType, equals, getAnnotation, getAnnotationMirrors, getKind, getModifiers, hashCode
-
-
-
-
Method Detail
-
getEnclosedElements
List<? extends Element> getEnclosedElements()
Returns the elements that are, loosely speaking, directly enclosed by this element. A class or interface is considered to enclose the fields, methods, constructors, and member types that it directly declares. This includes any (implicit) default constructor and the implicitvalues
andvalueOf
methods of an enum type. A package encloses the top-level classes and interfaces within it, but is not considered to enclose subpackages. Other kinds of elements are not currently considered to enclose any elements; however, that may change as this API or the programming language evolves.Note that elements of certain kinds can be isolated using methods in
ElementFilter
.Note that as a particular instance of the general accuracy requirements and the ordering behavior required of this interface, the list of enclosed elements will be returned in the natural order for the originating source of information about the type. For example, if the information about the type is originating from a source file, the elements will be returned in source code order. (However, in that case the the ordering of synthesized elements, such as a default constructor, is not specified.)
- Specified by:
getEnclosedElements
in interfaceElement
- Returns:
- the enclosed elements in proper order, or an empty list if none
- See Also:
Elements.getAllMembers(javax.lang.model.element.TypeElement)
-
getNestingKind
NestingKind getNestingKind()
Returns the nesting kind of this type element.- Returns:
- the nesting kind of this type element
-
getQualifiedName
Name getQualifiedName()
Returns the fully qualified name of this type element. More precisely, it returns the canonical name. For local and anonymous classes, which do not have canonical names, an empty name is returned.The name of a generic type does not include any reference to its formal type parameters. For example, the fully qualified name of the interface
java.util.Set<E>
is "java.util.Set
". Nested types use ".
" as a separator, as in "java.util.Map.Entry
".- Specified by:
getQualifiedName
in interfaceQualifiedNameable
- Returns:
- the fully qualified name of this class or interface, or an empty name if none
- See Also:
Elements.getBinaryName(javax.lang.model.element.TypeElement)
- See The Java™ Language Specification:
- 6.7 Fully Qualified Names and Canonical Names
-
getSimpleName
Name getSimpleName()
Returns the simple name of this type element. For an anonymous class, an empty name is returned.- Specified by:
getSimpleName
in interfaceElement
- Returns:
- the simple name of this class or interface, an empty name for an anonymous class
-
getSuperclass
TypeMirror getSuperclass()
Returns the direct superclass of this type element. If this type element represents an interface or the classjava.lang.Object
, then aNoType
with kindNONE
is returned.- Returns:
- the direct superclass, or a
NoType
if there is none
-
getInterfaces
List<? extends TypeMirror> getInterfaces()
Returns the interface types directly implemented by this class or extended by this interface.- Returns:
- the interface types directly implemented by this class or extended by this interface, or an empty list if there are none
-
getTypeParameters
List<? extends TypeParameterElement> getTypeParameters()
Returns the formal type parameters of this type element in declaration order.- Specified by:
getTypeParameters
in interfaceParameterizable
- Returns:
- the formal type parameters, or an empty list if there are none
-
getEnclosingElement
Element getEnclosingElement()
Returns the package of a top-level type and returns the immediately lexically enclosing element for a nested type.- Specified by:
getEnclosingElement
in interfaceElement
- Returns:
- the package of a top-level type, the immediately lexically enclosing element for a nested type
- See Also:
Elements.getPackageOf(javax.lang.model.element.Element)
-
-
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 11/06/2005 gemaakt, de laatste keer de 04/03/2020 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-rf-javax/lang/model/element/TypeElement.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.
Referenties
Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.