src/java.compiler/share/classes/javax/lang/model/element/Element.java
author darcy
Wed, 27 Sep 2017 14:23:41 -0700
changeset 47283 ce5fd3ba3fea
parent 47216 71c04702a3d5
child 54952 a978d86ac389
permissions -rw-r--r--
8187982: Update SourceVersion to mention restricted keywords Reviewed-by: mcimadamore
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
43567
d0d89c3da7be 8173676: Improvements to javax.annotation.processing and javax.lang.model doc
darcy
parents: 36526
diff changeset
     2
 * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    23
 * questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
package javax.lang.model.element;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
import java.lang.annotation.Annotation;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
import java.lang.annotation.AnnotationTypeMismatchException;
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
import java.lang.annotation.IncompleteAnnotationException;
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
import java.util.List;
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
import java.util.Set;
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
import javax.lang.model.type.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
import javax.lang.model.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
/**
43567
d0d89c3da7be 8173676: Improvements to javax.annotation.processing and javax.lang.model doc
darcy
parents: 36526
diff changeset
    40
 * Represents a program element such as a module, package, class, or method.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 * Each element represents a static, language-level construct
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
 * (and not, for example, a runtime construct of the virtual machine).
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
 * <p> Elements should be compared using the {@link #equals(Object)}
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
 * method.  There is no guarantee that any particular element will
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
 * always be represented by the same object.
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
 * <p> To implement operations based on the class of an {@code
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
 * Element} object, either use a {@linkplain ElementVisitor visitor} or
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
 * use the result of the {@link #getKind} method.  Using {@code
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
 * instanceof} is <em>not</em> necessarily a reliable idiom for
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
 * determining the effective class of an object in this modeling
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
 * hierarchy since an implementation may choose to have a single object
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
 * implement multiple {@code Element} subinterfaces.
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
 * @author Joseph D. Darcy
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
 * @author Scott Seligman
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
 * @author Peter von der Ah&eacute;
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
 * @see Elements
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
 * @see TypeMirror
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
 * @since 1.6
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
 */
16557
67a3ae363f03 8007803: Implement javax.lang.model API for Type Annotations
jjg
parents: 15719
diff changeset
    63
public interface Element extends javax.lang.model.AnnotatedConstruct {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
     * Returns the type defined by this element.
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
     * <p> A generic element defines a family of types, not just one.
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
     * If this is a generic element, a <i>prototypical</i> type is
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
     * returned.  This is the element's invocation on the
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
     * type variables corresponding to its own formal type parameters.
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
     * For example,
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
     * for the generic class element {@code C<N extends Number>},
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
     * the parameterized type {@code C<N>} is returned.
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
     * The {@link Types} utility interface has more general methods
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
     * for obtaining the full range of types defined by an element.
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
     * @see Types
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
     * @return the type defined by this element
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
    TypeMirror asType();
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
     * Returns the {@code kind} of this element.
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
     * @return the kind of this element
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
    ElementKind getKind();
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
     * Returns the modifiers of this element, excluding annotations.
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
     * Implicit modifiers, such as the {@code public} and {@code static}
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
     * modifiers of interface members, are included.
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
     * @return the modifiers of this element, or an empty set if there are none
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
    Set<Modifier> getModifiers();
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
    /**
8233
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   100
     * Returns the simple (unqualified) name of this element.  The
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   101
     * name of a generic type does not include any reference to its
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   102
     * formal type parameters.
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   103
     *
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   104
     * For example, the simple name of the type element {@code
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   105
     * java.util.Set<E>} is {@code "Set"}.
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   106
     *
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   107
     * If this element represents an unnamed {@linkplain
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   108
     * PackageElement#getSimpleName package} or unnamed {@linkplain
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   109
     * ModuleElement#getSimpleName module}, an empty name is returned.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
     *
8233
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   111
     * If it represents a {@linkplain ExecutableElement#getSimpleName
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   112
     * constructor}, the name "{@code <init>}" is returned.  If it
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   113
     * represents a {@linkplain ExecutableElement#getSimpleName static
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   114
     * initializer}, the name "{@code <clinit>}" is returned.
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   115
     *
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   116
     * If it represents an {@linkplain TypeElement#getSimpleName
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   117
     * anonymous class} or {@linkplain ExecutableElement#getSimpleName
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   118
     * instance initializer}, an empty name is returned.
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   119
     *
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
     * @return the simple name of this element
15042
88ce00b3841a 8004730: Add language model support for parameter reflection
darcy
parents: 14258
diff changeset
   121
     * @see PackageElement#getSimpleName
88ce00b3841a 8004730: Add language model support for parameter reflection
darcy
parents: 14258
diff changeset
   122
     * @see ExecutableElement#getSimpleName
88ce00b3841a 8004730: Add language model support for parameter reflection
darcy
parents: 14258
diff changeset
   123
     * @see TypeElement#getSimpleName
88ce00b3841a 8004730: Add language model support for parameter reflection
darcy
parents: 14258
diff changeset
   124
     * @see VariableElement#getSimpleName
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   125
     * @see ModuleElement#getSimpleName
43767
9cff98a149cb 8173393: Module system implementation refresh (2/2017)
alanb
parents: 43589
diff changeset
   126
     * @revised 9
9cff98a149cb 8173393: Module system implementation refresh (2/2017)
alanb
parents: 43589
diff changeset
   127
     * @spec JPMS
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
    Name getSimpleName();
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
     * Returns the innermost element
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
     * within which this element is, loosely speaking, enclosed.
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
     * <ul>
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
     * <li> If this element is one whose declaration is lexically enclosed
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
     * immediately within the declaration of another element, that other
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
     * element is returned.
8233
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   138
     *
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   139
     * <li> If this is a {@linkplain TypeElement#getEnclosingElement
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   140
     * top-level type}, its package is returned.
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   141
     *
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   142
     * <li> If this is a {@linkplain
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   143
     * PackageElement#getEnclosingElement package}, its module is
43571
a153580d1741 8173776: More javax.lang.model improvements to support modules
darcy
parents: 43567
diff changeset
   144
     * returned if such a module exists. Otherwise, {@code null} is returned.
8840
a321232a781c 7026868: Apply specification changes fro 6505047
darcy
parents: 8233
diff changeset
   145
     *
8233
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   146
     * <li> If this is a {@linkplain
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
   147
     * TypeParameterElement#getEnclosingElement type parameter},
8840
a321232a781c 7026868: Apply specification changes fro 6505047
darcy
parents: 8233
diff changeset
   148
     * {@linkplain TypeParameterElement#getGenericElement the
a321232a781c 7026868: Apply specification changes fro 6505047
darcy
parents: 8233
diff changeset
   149
     * generic element} of the type parameter is returned.
a321232a781c 7026868: Apply specification changes fro 6505047
darcy
parents: 8233
diff changeset
   150
     *
15042
88ce00b3841a 8004730: Add language model support for parameter reflection
darcy
parents: 14258
diff changeset
   151
     * <li> If this is a {@linkplain
88ce00b3841a 8004730: Add language model support for parameter reflection
darcy
parents: 14258
diff changeset
   152
     * VariableElement#getEnclosingElement method or constructor
88ce00b3841a 8004730: Add language model support for parameter reflection
darcy
parents: 14258
diff changeset
   153
     * parameter}, {@linkplain ExecutableElement the executable
88ce00b3841a 8004730: Add language model support for parameter reflection
darcy
parents: 14258
diff changeset
   154
     * element} which declares the parameter is returned.
88ce00b3841a 8004730: Add language model support for parameter reflection
darcy
parents: 14258
diff changeset
   155
     *
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   156
     * <li> If this is a {@linkplain ModuleElement#getEnclosingElement
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   157
     * module}, {@code null} is returned.
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   158
     *
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
     * </ul>
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
     * @return the enclosing element, or {@code null} if there is none
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
     * @see Elements#getPackageOf
43767
9cff98a149cb 8173393: Module system implementation refresh (2/2017)
alanb
parents: 43589
diff changeset
   163
     * @revised 9
9cff98a149cb 8173393: Module system implementation refresh (2/2017)
alanb
parents: 43589
diff changeset
   164
     * @spec JPMS
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
    Element getEnclosingElement();
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
     * Returns the elements that are, loosely speaking, directly
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
     * enclosed by this element.
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
     *
11553
4389b722f8dc 7130768: Clarify behavior of Element.getEnclosingElements in subtypes
darcy
parents: 9303
diff changeset
   172
     * A {@linkplain TypeElement#getEnclosedElements class or
4389b722f8dc 7130768: Clarify behavior of Element.getEnclosingElements in subtypes
darcy
parents: 9303
diff changeset
   173
     * interface} is considered to enclose the fields, methods,
4389b722f8dc 7130768: Clarify behavior of Element.getEnclosingElements in subtypes
darcy
parents: 9303
diff changeset
   174
     * constructors, and member types that it directly declares.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
     *
11553
4389b722f8dc 7130768: Clarify behavior of Element.getEnclosingElements in subtypes
darcy
parents: 9303
diff changeset
   176
     * A {@linkplain PackageElement#getEnclosedElements package}
4389b722f8dc 7130768: Clarify behavior of Element.getEnclosingElements in subtypes
darcy
parents: 9303
diff changeset
   177
     * encloses the top-level classes and interfaces within it, but is
4389b722f8dc 7130768: Clarify behavior of Element.getEnclosingElements in subtypes
darcy
parents: 9303
diff changeset
   178
     * not considered to enclose subpackages.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
     *
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   180
     * A {@linkplain ModuleElement#getEnclosedElements module}
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   181
     * encloses packages within it.
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   182
     *
43589
2e1691ced520 8173944: Reference Origin.MANDATED in getEnclosedElements specs
darcy
parents: 43571
diff changeset
   183
     * Enclosed elements may include implicitly declared {@linkplain
2e1691ced520 8173944: Reference Origin.MANDATED in getEnclosedElements specs
darcy
parents: 43571
diff changeset
   184
     * Elements.Origin#MANDATED mandated} elements.
2e1691ced520 8173944: Reference Origin.MANDATED in getEnclosedElements specs
darcy
parents: 43571
diff changeset
   185
     *
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
     * Other kinds of elements are not currently considered to enclose
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
     * any elements; however, that may change as this API or the
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
     * programming language evolves.
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
     *
43567
d0d89c3da7be 8173676: Improvements to javax.annotation.processing and javax.lang.model doc
darcy
parents: 36526
diff changeset
   190
     * @apiNote Elements of certain kinds can be isolated using
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
     * methods in {@link ElementFilter}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
     * @return the enclosed elements, or an empty list if none
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   194
     * @see TypeElement#getEnclosedElements
11553
4389b722f8dc 7130768: Clarify behavior of Element.getEnclosingElements in subtypes
darcy
parents: 9303
diff changeset
   195
     * @see PackageElement#getEnclosedElements
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   196
     * @see ModuleElement#getEnclosedElements
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
     * @see Elements#getAllMembers
9303
eae35c201e19 7032975: API files in javax.annotation.processing need to be updated for references to JLS
jjh
parents: 8840
diff changeset
   198
     * @jls 8.8.9 Default Constructor
eae35c201e19 7032975: API files in javax.annotation.processing need to be updated for references to JLS
jjh
parents: 8840
diff changeset
   199
     * @jls 8.9 Enums
43767
9cff98a149cb 8173393: Module system implementation refresh (2/2017)
alanb
parents: 43589
diff changeset
   200
     * @revised 9
9cff98a149cb 8173393: Module system implementation refresh (2/2017)
alanb
parents: 43589
diff changeset
   201
     * @spec JPMS
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
    List<? extends Element> getEnclosedElements();
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
     * Returns {@code true} if the argument represents the same
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
     * element as {@code this}, or {@code false} otherwise.
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
     *
43567
d0d89c3da7be 8173676: Improvements to javax.annotation.processing and javax.lang.model doc
darcy
parents: 36526
diff changeset
   209
     * @apiNote The identity of an element involves implicit state
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
     * not directly accessible from the element's methods, including
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
     * state about the presence of unrelated types.  Element objects
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
     * created by different implementations of these interfaces should
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
     * <i>not</i> be expected to be equal even if &quot;the same&quot;
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
     * element is being modeled; this is analogous to the inequality
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
     * of {@code Class} objects for the same class file loaded through
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
     * different class loaders.
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
     * @param obj  the object to be compared with this element
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
     * @return {@code true} if the specified object represents the same
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
     *          element as this
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
     */
20620
1562aa55640a 8026017: Make history of AnnotatedConstruct methods in jx.l.m.e.Element clearer
darcy
parents: 16557
diff changeset
   222
    @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
    boolean equals(Object obj);
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
     * Obeys the general contract of {@link Object#hashCode Object.hashCode}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
     * @see #equals
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
     */
20620
1562aa55640a 8026017: Make history of AnnotatedConstruct methods in jx.l.m.e.Element clearer
darcy
parents: 16557
diff changeset
   230
    @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
    int hashCode();
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
16557
67a3ae363f03 8007803: Implement javax.lang.model API for Type Annotations
jjg
parents: 15719
diff changeset
   233
67a3ae363f03 8007803: Implement javax.lang.model API for Type Annotations
jjg
parents: 15719
diff changeset
   234
    /**
67a3ae363f03 8007803: Implement javax.lang.model API for Type Annotations
jjg
parents: 15719
diff changeset
   235
     * {@inheritDoc}
67a3ae363f03 8007803: Implement javax.lang.model API for Type Annotations
jjg
parents: 15719
diff changeset
   236
     *
67a3ae363f03 8007803: Implement javax.lang.model API for Type Annotations
jjg
parents: 15719
diff changeset
   237
     * <p> To get inherited annotations as well, use {@link
67a3ae363f03 8007803: Implement javax.lang.model API for Type Annotations
jjg
parents: 15719
diff changeset
   238
     * Elements#getAllAnnotationMirrors(Element)
67a3ae363f03 8007803: Implement javax.lang.model API for Type Annotations
jjg
parents: 15719
diff changeset
   239
     * getAllAnnotationMirrors}.
67a3ae363f03 8007803: Implement javax.lang.model API for Type Annotations
jjg
parents: 15719
diff changeset
   240
     *
67a3ae363f03 8007803: Implement javax.lang.model API for Type Annotations
jjg
parents: 15719
diff changeset
   241
     * @since 1.6
67a3ae363f03 8007803: Implement javax.lang.model API for Type Annotations
jjg
parents: 15719
diff changeset
   242
     */
67a3ae363f03 8007803: Implement javax.lang.model API for Type Annotations
jjg
parents: 15719
diff changeset
   243
    @Override
67a3ae363f03 8007803: Implement javax.lang.model API for Type Annotations
jjg
parents: 15719
diff changeset
   244
    List<? extends AnnotationMirror> getAnnotationMirrors();
20620
1562aa55640a 8026017: Make history of AnnotatedConstruct methods in jx.l.m.e.Element clearer
darcy
parents: 16557
diff changeset
   245
1562aa55640a 8026017: Make history of AnnotatedConstruct methods in jx.l.m.e.Element clearer
darcy
parents: 16557
diff changeset
   246
    /**
1562aa55640a 8026017: Make history of AnnotatedConstruct methods in jx.l.m.e.Element clearer
darcy
parents: 16557
diff changeset
   247
     * {@inheritDoc}
1562aa55640a 8026017: Make history of AnnotatedConstruct methods in jx.l.m.e.Element clearer
darcy
parents: 16557
diff changeset
   248
     * @since 1.6
1562aa55640a 8026017: Make history of AnnotatedConstruct methods in jx.l.m.e.Element clearer
darcy
parents: 16557
diff changeset
   249
     */
1562aa55640a 8026017: Make history of AnnotatedConstruct methods in jx.l.m.e.Element clearer
darcy
parents: 16557
diff changeset
   250
    @Override
1562aa55640a 8026017: Make history of AnnotatedConstruct methods in jx.l.m.e.Element clearer
darcy
parents: 16557
diff changeset
   251
    <A extends Annotation> A getAnnotation(Class<A> annotationType);
1562aa55640a 8026017: Make history of AnnotatedConstruct methods in jx.l.m.e.Element clearer
darcy
parents: 16557
diff changeset
   252
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
     * Applies a visitor to this element.
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
     * @param <R> the return type of the visitor's methods
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
     * @param <P> the type of the additional parameter to the visitor's methods
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
     * @param v   the visitor operating on this element
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
     * @param p   additional parameter to the visitor
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
     * @return a visitor-specified result
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
    <R, P> R accept(ElementVisitor<R, P> v, P p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
}