src/share/classes/javax/lang/model/element/Element.java

Print this page


   1 /*
   2  * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 142      * @see #getAnnotationMirrors()
 143      * @see java.lang.reflect.AnnotatedElement#getAnnotation
 144      * @see EnumConstantNotPresentException
 145      * @see AnnotationTypeMismatchException
 146      * @see IncompleteAnnotationException
 147      * @see MirroredTypeException
 148      * @see MirroredTypesException
 149      */
 150     <A extends Annotation> A getAnnotation(Class<A> annotationType);
 151 
 152     /**
 153      * Returns the modifiers of this element, excluding annotations.
 154      * Implicit modifiers, such as the {@code public} and {@code static}
 155      * modifiers of interface members, are included.
 156      *
 157      * @return the modifiers of this element, or an empty set if there are none
 158      */
 159     Set<Modifier> getModifiers();
 160 
 161     /**
 162      * Returns the simple (unqualified) name of this element.
 163      * The name of a generic type does not include any reference
 164      * to its formal type parameters.
 165      * For example, the simple name of the type element
 166      * {@code java.util.Set<E>} is {@code "Set"}.
 167      * If this element represents an unnamed package, an empty name is
 168      * returned.  If it represents a constructor, the name "{@code
 169      * <init>}" is returned.  If it represents a static initializer,
 170      * the name "{@code <clinit>}" is returned.  If it represents an
 171      * anonymous class or instance initializer, an empty name is
 172      * returned.
 173      *









 174      * @return the simple name of this element
 175      */
 176     Name getSimpleName();
 177 
 178     /**
 179      * Returns the innermost element
 180      * within which this element is, loosely speaking, enclosed.
 181      * <ul>
 182      * <li> If this element is one whose declaration is lexically enclosed
 183      * immediately within the declaration of another element, that other
 184      * element is returned.
 185      * <li> If this is a top-level type, its package is returned.
 186      * <li> If this is a package, {@code null} is returned.
 187      * <li> If this is a type parameter, {@code null} is returned.









 188      * </ul>
 189      *
 190      * @return the enclosing element, or {@code null} if there is none
 191      * @see Elements#getPackageOf
 192      */
 193     Element getEnclosingElement();
 194 
 195     /**
 196      * Returns the elements that are, loosely speaking, directly
 197      * enclosed by this element.
 198      *
 199      * A class or interface is considered to enclose the fields,
 200      * methods, constructors, and member types that it directly
 201      * declares.  This includes any (implicit) default constructor and
 202      * the implicit {@code values} and {@code valueOf} methods of an
 203      * enum type.
 204      *
 205      * A package encloses the top-level classes and interfaces within
 206      * it, but is not considered to enclose subpackages.
 207      *


   1 /*
   2  * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 142      * @see #getAnnotationMirrors()
 143      * @see java.lang.reflect.AnnotatedElement#getAnnotation
 144      * @see EnumConstantNotPresentException
 145      * @see AnnotationTypeMismatchException
 146      * @see IncompleteAnnotationException
 147      * @see MirroredTypeException
 148      * @see MirroredTypesException
 149      */
 150     <A extends Annotation> A getAnnotation(Class<A> annotationType);
 151 
 152     /**
 153      * Returns the modifiers of this element, excluding annotations.
 154      * Implicit modifiers, such as the {@code public} and {@code static}
 155      * modifiers of interface members, are included.
 156      *
 157      * @return the modifiers of this element, or an empty set if there are none
 158      */
 159     Set<Modifier> getModifiers();
 160 
 161     /**
 162      * Returns the simple (unqualified) name of this element.  The
 163      * name of a generic type does not include any reference to its
 164      * formal type parameters.
 165      *
 166      * For example, the simple name of the type element {@code
 167      * java.util.Set<E>} is {@code "Set"}.
 168      *
 169      * If this element represents an unnamed {@linkplain
 170      * PackageElement#getSimpleName package}, an empty name is

 171      * returned.
 172      *
 173      * If it represents a {@linkplain ExecutableElement#getSimpleName
 174      * constructor}, the name "{@code <init>}" is returned.  If it
 175      * represents a {@linkplain ExecutableElement#getSimpleName static
 176      * initializer}, the name "{@code <clinit>}" is returned.
 177      *
 178      * If it represents an {@linkplain TypeElement#getSimpleName
 179      * anonymous class} or {@linkplain ExecutableElement#getSimpleName
 180      * instance initializer}, an empty name is returned.
 181      *
 182      * @return the simple name of this element
 183      */
 184     Name getSimpleName();
 185 
 186     /**
 187      * Returns the innermost element
 188      * within which this element is, loosely speaking, enclosed.
 189      * <ul>
 190      * <li> If this element is one whose declaration is lexically enclosed
 191      * immediately within the declaration of another element, that other
 192      * element is returned.
 193      *
 194      * <li> If this is a {@linkplain TypeElement#getEnclosingElement
 195      * top-level type}, its package is returned.
 196      *
 197      * <li> If this is a {@linkplain
 198      * PackageElement#getEnclosingElement package}, {@code null} is
 199      * returned.
 200 
 201      * <li> If this is a {@linkplain
 202      * TypeParameterElement#getEnclosingElement type parameter},
 203      * {@code null} is returned.
 204 
 205      * </ul>
 206      *
 207      * @return the enclosing element, or {@code null} if there is none
 208      * @see Elements#getPackageOf
 209      */
 210     Element getEnclosingElement();
 211 
 212     /**
 213      * Returns the elements that are, loosely speaking, directly
 214      * enclosed by this element.
 215      *
 216      * A class or interface is considered to enclose the fields,
 217      * methods, constructors, and member types that it directly
 218      * declares.  This includes any (implicit) default constructor and
 219      * the implicit {@code values} and {@code valueOf} methods of an
 220      * enum type.
 221      *
 222      * A package encloses the top-level classes and interfaces within
 223      * it, but is not considered to enclose subpackages.
 224      *