Interface PackageElement

All Superinterfaces:
AnnotatedConstruct, Element, QualifiedNameable
public interface PackageElement extends Element, QualifiedNameable
Represents a package program element. Provides access to information about the package and its members.
Since:
1.6
See Also:

Method Summary

Modifier and Type Method Description
TypeMirror asType()
Returns a pseudo-type for this package.
List<? extends Element> getEnclosedElements()
Returns the top-level classes and interfaces within this package.
Element getEnclosingElement()
Returns the enclosing module if such a module exists; otherwise null.
Name getQualifiedName()
Returns the fully qualified name of this package.
Name getSimpleName()
Returns the simple name of this package.
boolean isUnnamed()
Returns true if this is an unnamed package and false otherwise.

Methods declared in interface javax.lang.model.element.Element

accept, equals, getAnnotation, getAnnotationMirrors, getAnnotationsByType, getKind, getModifiers, hashCode

Method Details

asType

TypeMirror asType()
Returns a pseudo-type for this package.
Specified by:
asType in interface Element
Returns:
a pseudo-type for this package
See Also:

getQualifiedName

Name getQualifiedName()
Returns the fully qualified name of this package. This is also known as the package's canonical name. For an unnamed package, an empty name is returned.
Specified by:
getQualifiedName in interface QualifiedNameable
API Note:
The fully qualified name of a named package that is not a subpackage of a named package is its simple name. The fully qualified name of a named package that is a subpackage of another named package consists of the fully qualified name of the containing package, followed by ".", followed by the simple (member) name of the subpackage.
Returns:
the fully qualified name of this package, or an empty name if this is an unnamed package
See Java Language Specification:
6.7 Fully Qualified Names and Canonical Names

getSimpleName

Name getSimpleName()
Returns the simple name of this package. For an unnamed package, an empty name is returned.
Specified by:
getSimpleName in interface Element
Returns:
the simple name of this package or an empty name if this is an unnamed package
See Also:

getEnclosedElements

List<? extends Element> getEnclosedElements()
Returns the top-level classes and interfaces within this package. Note that subpackages are not considered to be enclosed by a package.
Specified by:
getEnclosedElements in interface Element
Returns:
the top-level classes and interfaces within this package
See Also:

isUnnamed

boolean isUnnamed()
Returns true if this is an unnamed package and false otherwise.
Returns:
true if this is an unnamed package and false otherwise
See Java Language Specification:
7.4.2 Unnamed Packages

getEnclosingElement

Element getEnclosingElement()
Returns the enclosing module if such a module exists; otherwise null. One situation where a module does not exist for a package is if the environment does not include modules, such as an annotation processing environment configured for a source version without modules.
Specified by:
getEnclosingElement in interface Element
Returns:
the enclosing module if such a module exists; otherwise null
See Also:

© 1993, 2021, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/17/docs/api/java.compiler/javax/lang/model/element/PackageElement.html