langtools/src/java.compiler/share/classes/javax/lang/model/util/Elements.java
author jlahoda
Fri, 16 Dec 2016 12:02:30 +0100
changeset 42824 89b14017e8d6
parent 37848 3c8ff4204d2d
child 42825 c22877f68145
permissions -rw-r--r--
8133896: Update javax.lang.model APIs Reviewed-by: darcy, jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
37848
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
     2
 * Copyright (c) 2005, 2016, 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: 4074
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: 4074
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: 4074
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 4074
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 4074
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.util;
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.util.List;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
import java.util.Map;
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
import javax.lang.model.element.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 * Utility methods for operating on program elements.
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 * <p><b>Compatibility Note:</b> Methods may be added to this interface
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 * in future releases of the platform.
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 * @author Joseph D. Darcy
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
 * @author Scott Seligman
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
 * @author Peter von der Ah&eacute;
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
 * @see javax.annotation.processing.ProcessingEnvironment#getElementUtils
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
 * @since 1.6
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
public interface Elements {
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
    /**
42824
89b14017e8d6 8133896: Update javax.lang.model APIs
jlahoda
parents: 37848
diff changeset
    50
     * Returns a package given its fully qualified name if the package is unique in the environment.
89b14017e8d6 8133896: Update javax.lang.model APIs
jlahoda
parents: 37848
diff changeset
    51
     * If running with modules, all modules in the modules graph are searched for matching packages.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
     *
37848
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    53
     * @param name  fully qualified package name, or an empty string for an unnamed package
42824
89b14017e8d6 8133896: Update javax.lang.model APIs
jlahoda
parents: 37848
diff changeset
    54
     * @return the named package, or {@code null} if it cannot be uniquely found
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
    PackageElement getPackageElement(CharSequence name);
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
    /**
37848
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    59
     * Returns a package given its fully qualified name, as seen from the given module.
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    60
     *
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    61
     * @param name  fully qualified package name, or an empty string for an unnamed package
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    62
     * @param module module relative to which the lookup should happen
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    63
     * @return the named package, or {@code null} if it cannot be found
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    64
     * @since 9
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    65
     */
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    66
    PackageElement getPackageElement(ModuleElement module, CharSequence name);
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    67
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    68
    /**
42824
89b14017e8d6 8133896: Update javax.lang.model APIs
jlahoda
parents: 37848
diff changeset
    69
     * Returns a type element given its canonical name if the type element is unique in the environment.
89b14017e8d6 8133896: Update javax.lang.model APIs
jlahoda
parents: 37848
diff changeset
    70
     * If running with modules, all modules in the modules graph are searched for matching
89b14017e8d6 8133896: Update javax.lang.model APIs
jlahoda
parents: 37848
diff changeset
    71
     * type elements.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
     * @param name  the canonical name
42824
89b14017e8d6 8133896: Update javax.lang.model APIs
jlahoda
parents: 37848
diff changeset
    74
     * @return the named type element, or {@code null} if it cannot be uniquely found
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
    TypeElement getTypeElement(CharSequence name);
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
    /**
37848
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    79
     * Returns a type element given its canonical name, as seen from the given module.
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    80
     *
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    81
     * @param name  the canonical name
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    82
     * @param module module relative to which the lookup should happen
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    83
     * @return the named type element, or {@code null} if it cannot be found
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    84
     * @since 9
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    85
     */
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    86
    TypeElement getTypeElement(ModuleElement module, CharSequence name);
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    87
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    88
    /**
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    89
     * Returns a module element given its fully qualified name.
42824
89b14017e8d6 8133896: Update javax.lang.model APIs
jlahoda
parents: 37848
diff changeset
    90
     * If the named module cannot be found, null is returned. One situation where a module
89b14017e8d6 8133896: Update javax.lang.model APIs
jlahoda
parents: 37848
diff changeset
    91
     * cannot be found is if the environment does not include modules, such as
89b14017e8d6 8133896: Update javax.lang.model APIs
jlahoda
parents: 37848
diff changeset
    92
     * an annotation processing environment configured for
89b14017e8d6 8133896: Update javax.lang.model APIs
jlahoda
parents: 37848
diff changeset
    93
     * a {@linkplain ProcessingEnvironment#getSourceVersion source version} without modules.      *
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    94
     *
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    95
     * @param name  the name
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    96
     * @return the named module element, or {@code null} if it cannot be found
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    97
     * @since 9
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    98
     */
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    99
    ModuleElement getModuleElement(CharSequence name);
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   100
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   101
    /**
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
     * Returns the values of an annotation's elements, including defaults.
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
     * @see AnnotationMirror#getElementValues()
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
     * @param a  annotation to examine
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
     * @return the values of the annotation's elements, including defaults
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
    Map<? extends ExecutableElement, ? extends AnnotationValue>
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
            getElementValuesWithDefaults(AnnotationMirror a);
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
     * Returns the text of the documentation (&quot;Javadoc&quot;)
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
     * comment of an element.
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
     *
4074
2b391dcb03ff 6558804: Specification for Elements.getDocComment(Element e) should be clarified
darcy
parents: 10
diff changeset
   115
     * <p> A documentation comment of an element is a comment that
2b391dcb03ff 6558804: Specification for Elements.getDocComment(Element e) should be clarified
darcy
parents: 10
diff changeset
   116
     * begins with "{@code /**}" , ends with a separate
13844
56339cf983a3 7177970: fix issues in langtools doc comments
jjg
parents: 9303
diff changeset
   117
     * "<code>*&#47;</code>", and immediately precedes the element,
4074
2b391dcb03ff 6558804: Specification for Elements.getDocComment(Element e) should be clarified
darcy
parents: 10
diff changeset
   118
     * ignoring white space.  Therefore, a documentation comment
2b391dcb03ff 6558804: Specification for Elements.getDocComment(Element e) should be clarified
darcy
parents: 10
diff changeset
   119
     * contains at least three"{@code *}" characters.  The text
2b391dcb03ff 6558804: Specification for Elements.getDocComment(Element e) should be clarified
darcy
parents: 10
diff changeset
   120
     * returned for the documentation comment is a processed form of
2b391dcb03ff 6558804: Specification for Elements.getDocComment(Element e) should be clarified
darcy
parents: 10
diff changeset
   121
     * the comment as it appears in source code.  The leading "{@code
13844
56339cf983a3 7177970: fix issues in langtools doc comments
jjg
parents: 9303
diff changeset
   122
     * /**}" and trailing "<code>*&#47;</code>" are removed.  For lines
4074
2b391dcb03ff 6558804: Specification for Elements.getDocComment(Element e) should be clarified
darcy
parents: 10
diff changeset
   123
     * of the comment starting after the initial "{@code /**}",
2b391dcb03ff 6558804: Specification for Elements.getDocComment(Element e) should be clarified
darcy
parents: 10
diff changeset
   124
     * leading white space characters are discarded as are any
2b391dcb03ff 6558804: Specification for Elements.getDocComment(Element e) should be clarified
darcy
parents: 10
diff changeset
   125
     * consecutive "{@code *}" characters appearing after the white
2b391dcb03ff 6558804: Specification for Elements.getDocComment(Element e) should be clarified
darcy
parents: 10
diff changeset
   126
     * space or starting the line.  The processed lines are then
2b391dcb03ff 6558804: Specification for Elements.getDocComment(Element e) should be clarified
darcy
parents: 10
diff changeset
   127
     * concatenated together (including line terminators) and
2b391dcb03ff 6558804: Specification for Elements.getDocComment(Element e) should be clarified
darcy
parents: 10
diff changeset
   128
     * returned.
2b391dcb03ff 6558804: Specification for Elements.getDocComment(Element e) should be clarified
darcy
parents: 10
diff changeset
   129
     *
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
     * @param e  the element being examined
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
     * @return the documentation comment of the element, or {@code null}
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
     *          if there is none
9303
eae35c201e19 7032975: API files in javax.annotation.processing need to be updated for references to JLS
jjh
parents: 5520
diff changeset
   133
     * @jls 3.6 White Space
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
    String getDocComment(Element e);
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
     * Returns {@code true} if the element is deprecated, {@code false} otherwise.
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
     * @param e  the element being examined
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
     * @return {@code true} if the element is deprecated, {@code false} otherwise
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
    boolean isDeprecated(Element e);
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
     * Returns the <i>binary name</i> of a type element.
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
     * @param type  the type element being examined
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
     * @return the binary name
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
     * @see TypeElement#getQualifiedName
9303
eae35c201e19 7032975: API files in javax.annotation.processing need to be updated for references to JLS
jjh
parents: 5520
diff changeset
   152
     * @jls 13.1 The Form of a Binary
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
    Name getBinaryName(TypeElement type);
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
     * Returns the package of an element.  The package of a package is
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
     * itself.
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
     * @param type the element being examined
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
     * @return the package of an element
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
    PackageElement getPackageOf(Element type);
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
    /**
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   167
     * Returns the module of an element.  The module of a module is
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   168
     * itself.
42824
89b14017e8d6 8133896: Update javax.lang.model APIs
jlahoda
parents: 37848
diff changeset
   169
     * If there is no module for the element, null is returned. One situation where there is
89b14017e8d6 8133896: Update javax.lang.model APIs
jlahoda
parents: 37848
diff changeset
   170
     * no module for an element is if the environment does not include modules, such as
89b14017e8d6 8133896: Update javax.lang.model APIs
jlahoda
parents: 37848
diff changeset
   171
     * an annotation processing environment configured for
89b14017e8d6 8133896: Update javax.lang.model APIs
jlahoda
parents: 37848
diff changeset
   172
     * a {@linkplain ProcessingEnvironment#getSourceVersion source version} without modules.      *
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   173
     *
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   174
     * @param type the element being examined
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   175
     * @return the module of an element
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   176
     * @since 9
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   177
     */
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   178
    ModuleElement getModuleOf(Element type);
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   179
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   180
    /**
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
     * Returns all members of a type element, whether inherited or
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
     * declared directly.  For a class the result also includes its
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
     * constructors, but not local or anonymous classes.
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
     * <p>Note that elements of certain kinds can be isolated using
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
     * methods in {@link ElementFilter}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
     * @param type  the type being examined
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
     * @return all members of the type
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
     * @see Element#getEnclosedElements
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
    List<? extends Element> getAllMembers(TypeElement type);
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
    /**
17802
83c53847fc7e 8010680: Clarify "present" and annotation ordering in javax.lang.model
darcy
parents: 17548
diff changeset
   195
     * Returns all annotations <i>present</i> on an element, whether
83c53847fc7e 8010680: Clarify "present" and annotation ordering in javax.lang.model
darcy
parents: 17548
diff changeset
   196
     * directly present or present via inheritance.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
     * @param e  the element being examined
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
     * @return all annotations of the element
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
     * @see Element#getAnnotationMirrors
17802
83c53847fc7e 8010680: Clarify "present" and annotation ordering in javax.lang.model
darcy
parents: 17548
diff changeset
   201
     * @see javax.lang.model.AnnotatedConstruct
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
    List<? extends AnnotationMirror> getAllAnnotationMirrors(Element e);
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
     * Tests whether one type, method, or field hides another.
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
     * @param hider   the first element
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
     * @param hidden  the second element
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
     * @return {@code true} if and only if the first element hides
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
     *          the second
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
    boolean hides(Element hider, Element hidden);
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
     * Tests whether one method, as a member of a given type,
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
     * overrides another method.
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
     * When a non-abstract method overrides an abstract one, the
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
     * former is also said to <i>implement</i> the latter.
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
     * <p> In the simplest and most typical usage, the value of the
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
     * {@code type} parameter will simply be the class or interface
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
     * directly enclosing {@code overrider} (the possibly-overriding
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
     * method).  For example, suppose {@code m1} represents the method
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
     * {@code String.hashCode} and {@code m2} represents {@code
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
     * Object.hashCode}.  We can then ask whether {@code m1} overrides
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
     * {@code m2} within the class {@code String} (it does):
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
     * <blockquote>
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
     * {@code assert elements.overrides(m1, m2,
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
     *          elements.getTypeElement("java.lang.String")); }
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
     * </blockquote>
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
     * A more interesting case can be illustrated by the following example
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
     * in which a method in type {@code A} does not override a
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
     * like-named method in type {@code B}:
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
     * <blockquote>
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
     * {@code class A { public void m() {} } }<br>
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
     * {@code interface B { void m(); } }<br>
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
     * ...<br>
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
     * {@code m1 = ...;  // A.m }<br>
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
     * {@code m2 = ...;  // B.m }<br>
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
     * {@code assert ! elements.overrides(m1, m2,
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
     *          elements.getTypeElement("A")); }
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
     * </blockquote>
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
     * When viewed as a member of a third type {@code C}, however,
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
     * the method in {@code A} does override the one in {@code B}:
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
     * <blockquote>
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
     * {@code class C extends A implements B {} }<br>
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
     * ...<br>
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
     * {@code assert elements.overrides(m1, m2,
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
     *          elements.getTypeElement("C")); }
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
     * </blockquote>
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
     * @param overrider  the first method, possible overrider
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
     * @param overridden  the second method, possibly being overridden
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
     * @param type   the type of which the first method is a member
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
     * @return {@code true} if and only if the first method overrides
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
     *          the second
9303
eae35c201e19 7032975: API files in javax.annotation.processing need to be updated for references to JLS
jjh
parents: 5520
diff changeset
   263
     * @jls 8.4.8 Inheritance, Overriding, and Hiding
eae35c201e19 7032975: API files in javax.annotation.processing need to be updated for references to JLS
jjh
parents: 5520
diff changeset
   264
     * @jls 9.4.1 Inheritance and Overriding
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
    boolean overrides(ExecutableElement overrider, ExecutableElement overridden,
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
                      TypeElement type);
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
     * Returns the text of a <i>constant expression</i> representing a
06bc494ca11e Initial load
duke
parents:
diff changeset
   271
     * primitive value or a string.
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
     * The text returned is in a form suitable for representing the value
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
     * in source code.
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
     * @param value  a primitive value or string
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
     * @return the text of a constant expression
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
     * @throws IllegalArgumentException if the argument is not a primitive
06bc494ca11e Initial load
duke
parents:
diff changeset
   278
     *          value or string
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
     * @see VariableElement#getConstantValue()
06bc494ca11e Initial load
duke
parents:
diff changeset
   281
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
    String getConstantExpression(Object value);
06bc494ca11e Initial load
duke
parents:
diff changeset
   283
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   285
     * Prints a representation of the elements to the given writer in
06bc494ca11e Initial load
duke
parents:
diff changeset
   286
     * the specified order.  The main purpose of this method is for
06bc494ca11e Initial load
duke
parents:
diff changeset
   287
     * diagnostics.  The exact format of the output is <em>not</em>
06bc494ca11e Initial load
duke
parents:
diff changeset
   288
     * specified and is subject to change.
06bc494ca11e Initial load
duke
parents:
diff changeset
   289
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   290
     * @param w the writer to print the output to
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
     * @param elements the elements to print
06bc494ca11e Initial load
duke
parents:
diff changeset
   292
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   293
    void printElements(java.io.Writer w, Element... elements);
06bc494ca11e Initial load
duke
parents:
diff changeset
   294
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   296
     * Return a name with the same sequence of characters as the
06bc494ca11e Initial load
duke
parents:
diff changeset
   297
     * argument.
06bc494ca11e Initial load
duke
parents:
diff changeset
   298
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   299
     * @param cs the character sequence to return as a name
17548
b0a4fd89079c 8013909: Fix doclint issues in javax.lang.model
darcy
parents: 15714
diff changeset
   300
     * @return a name with the same sequence of characters as the argument
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   301
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   302
    Name getName(CharSequence cs);
15714
d9a83ab62853 8007574: Provide isFunctionalInterface in javax.lang.model
darcy
parents: 13844
diff changeset
   303
d9a83ab62853 8007574: Provide isFunctionalInterface in javax.lang.model
darcy
parents: 13844
diff changeset
   304
    /**
d9a83ab62853 8007574: Provide isFunctionalInterface in javax.lang.model
darcy
parents: 13844
diff changeset
   305
     * Returns {@code true} if the type element is a functional interface, {@code false} otherwise.
d9a83ab62853 8007574: Provide isFunctionalInterface in javax.lang.model
darcy
parents: 13844
diff changeset
   306
     *
d9a83ab62853 8007574: Provide isFunctionalInterface in javax.lang.model
darcy
parents: 13844
diff changeset
   307
     * @param type the type element being examined
d9a83ab62853 8007574: Provide isFunctionalInterface in javax.lang.model
darcy
parents: 13844
diff changeset
   308
     * @return {@code true} if the element is a functional interface, {@code false} otherwise
d9a83ab62853 8007574: Provide isFunctionalInterface in javax.lang.model
darcy
parents: 13844
diff changeset
   309
     * @jls 9.8 Functional Interfaces
d9a83ab62853 8007574: Provide isFunctionalInterface in javax.lang.model
darcy
parents: 13844
diff changeset
   310
     * @since 1.8
d9a83ab62853 8007574: Provide isFunctionalInterface in javax.lang.model
darcy
parents: 13844
diff changeset
   311
     */
d9a83ab62853 8007574: Provide isFunctionalInterface in javax.lang.model
darcy
parents: 13844
diff changeset
   312
    boolean isFunctionalInterface(TypeElement type);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   313
}