Interface Declaration
- All Known Subinterfaces:
AnnotationTypeDeclaration
,AnnotationTypeElementDeclaration
,ClassDeclaration
,ConstructorDeclaration
,EnumConstantDeclaration
,EnumDeclaration
,ExecutableDeclaration
,FieldDeclaration
,InterfaceDeclaration
,MemberDeclaration
,MethodDeclaration
,PackageDeclaration
,ParameterDeclaration
,TypeDeclaration
,TypeParameterDeclaration
Declarations should be compared using the equals(Object)
method. There is no guarantee that any particular declaration will
always be represented by the same object.
- Since:
- 1.5
- Version:
- 1.6 04/07/16
- Author:
- Joseph D. Darcy, Scott Seligman
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Applies a visitor to this declaration.boolean
Tests whether an object represents the same declaration as this.<A extends Annotation>
AgetAnnotation
(Class<A> annotationType) Returns the annotation of this declaration having the specified type.Returns the annotations that are directly present on this declaration.Returns the text of the documentation ("javadoc") comment of this declaration.Returns the modifiers of this declaration, excluding annotations.Returns the source position of the beginning of this declaration.Returns the simple (unqualified) name of this declaration.
-
Method Details
-
equals
Tests whether an object represents the same declaration as this. -
getDocComment
String getDocComment()Returns the text of the documentation ("javadoc") comment of this declaration.- Returns:
- the documentation comment of this declaration, or
null
if there is none
-
getAnnotationMirrors
Collection<AnnotationMirror> getAnnotationMirrors()Returns the annotations that are directly present on this declaration.- Returns:
- the annotations directly present on this declaration; an empty collection if there are none
-
getAnnotation
Returns the annotation of this declaration having the specified type. The annotation may be either inherited or directly present on this declaration.The annotation returned by this method could contain an element whose value is of type
Class
. This value cannot be returned directly: information necessary to locate and load a class (such as the class loader to use) is not available, and the class might not be loadable at all. Attempting to read aClass
object by invoking the relevant method on the returned annotation will result in aMirroredTypeException
, from which the correspondingTypeMirror
may be extracted. Similarly, attempting to read aClass[]
-valued element will result in aMirroredTypesException
.Note: This method is unlike others in this and related interfaces. It operates on run-time reflective information -- representations of annotation types currently loaded into the VM -- rather than on the mirrored representations defined by and used throughout these interfaces. It is intended for callers that are written to operate on a known, fixed set of annotation types.
- Type Parameters:
A
- the annotation type- Parameters:
annotationType
- theClass
object corresponding to the annotation type- Returns:
- the annotation of this declaration having the specified type
- See Also:
-
getModifiers
Collection<Modifier> getModifiers()Returns the modifiers of this declaration, excluding annotations. Implicit modifiers, such as thepublic
andstatic
modifiers of interface members, are included.- Returns:
- the modifiers of this declaration in undefined order; an empty collection if there are none
-
getSimpleName
String getSimpleName()Returns the simple (unqualified) name of this declaration. The name of a generic type does not include any reference to its formal type parameters. For example, the simple name of the interface declarationjava.util.Set<E>
is"Set"
. If this declaration represents the empty package, an empty string is returned. If it represents a constructor, the simple name of its declaring class is returned.- Returns:
- the simple name of this declaration
-
getPosition
SourcePosition getPosition()Returns the source position of the beginning of this declaration. Returnsnull
if the position is unknown or not applicable.This source position is intended for use in providing diagnostics, and indicates only approximately where a declaration begins.
- Returns:
- the source position of the beginning of this declaration, or null if the position is unknown or not applicable
-
accept
Applies a visitor to this declaration.- Parameters:
v
- the visitor operating on this declaration
-