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

Thu, 31 Aug 2017 15:17:03 +0800

author
aoqi
date
Thu, 31 Aug 2017 15:17:03 +0800
changeset 2525
2eb010b6cb22
parent 2227
998b10c43157
parent 0
959103a6100f
permissions
-rw-r--r--

merge

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation. Oracle designates this
aoqi@0 8 * particular file as subject to the "Classpath" exception as provided
aoqi@0 9 * by Oracle in the LICENSE file that accompanied this code.
aoqi@0 10 *
aoqi@0 11 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 14 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 15 * accompanied this code).
aoqi@0 16 *
aoqi@0 17 * You should have received a copy of the GNU General Public License version
aoqi@0 18 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 20 *
aoqi@0 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 22 * or visit www.oracle.com if you need additional information or have any
aoqi@0 23 * questions.
aoqi@0 24 */
aoqi@0 25
aoqi@0 26 package javax.lang.model.element;
aoqi@0 27
aoqi@0 28 import java.util.List;
aoqi@0 29 import javax.lang.model.type.*;
aoqi@0 30 import javax.lang.model.util.*;
aoqi@0 31
aoqi@0 32 /**
aoqi@0 33 * Represents a class or interface program element. Provides access
aoqi@0 34 * to information about the type and its members. Note that an enum
aoqi@0 35 * type is a kind of class and an annotation type is a kind of
aoqi@0 36 * interface.
aoqi@0 37 *
aoqi@0 38 * <p> <a name="ELEM_VS_TYPE"></a>
aoqi@0 39 * While a {@code TypeElement} represents a class or interface
aoqi@0 40 * <i>element</i>, a {@link DeclaredType} represents a class
aoqi@0 41 * or interface <i>type</i>, the latter being a use
aoqi@0 42 * (or <i>invocation</i>) of the former.
aoqi@0 43 * The distinction is most apparent with generic types,
aoqi@0 44 * for which a single element can define a whole
aoqi@0 45 * family of types. For example, the element
aoqi@0 46 * {@code java.util.Set} corresponds to the parameterized types
aoqi@0 47 * {@code java.util.Set<String>} and {@code java.util.Set<Number>}
aoqi@0 48 * (and many others), and to the raw type {@code java.util.Set}.
aoqi@0 49 *
aoqi@0 50 * <p> Each method of this interface that returns a list of elements
aoqi@0 51 * will return them in the order that is natural for the underlying
aoqi@0 52 * source of program information. For example, if the underlying
aoqi@0 53 * source of information is Java source code, then the elements will be
aoqi@0 54 * returned in source code order.
aoqi@0 55 *
aoqi@0 56 * @author Joseph D. Darcy
aoqi@0 57 * @author Scott Seligman
aoqi@0 58 * @author Peter von der Ah&eacute;
aoqi@0 59 * @see DeclaredType
aoqi@0 60 * @since 1.6
aoqi@0 61 */
aoqi@0 62 public interface TypeElement extends Element, Parameterizable, QualifiedNameable {
aoqi@0 63 /**
aoqi@0 64 * Returns the fields, methods, constructors, and member types
aoqi@0 65 * that are directly declared in this class or interface.
aoqi@0 66 *
aoqi@0 67 * This includes any (implicit) default constructor and
aoqi@0 68 * the implicit {@code values} and {@code valueOf} methods of an
aoqi@0 69 * enum type.
aoqi@0 70 *
aoqi@0 71 * <p> Note that as a particular instance of the {@linkplain
aoqi@0 72 * javax.lang.model.element general accuracy requirements} and the
aoqi@0 73 * ordering behavior required of this interface, the list of
aoqi@0 74 * enclosed elements will be returned in the natural order for the
aoqi@0 75 * originating source of information about the type. For example,
aoqi@0 76 * if the information about the type is originating from a source
aoqi@0 77 * file, the elements will be returned in source code order.
aoqi@0 78 * (However, in that case the the ordering of synthesized
aoqi@0 79 * elements, such as a default constructor, is not specified.)
aoqi@0 80 *
aoqi@0 81 * @return the enclosed elements in proper order, or an empty list if none
aoqi@0 82 */
aoqi@0 83 @Override
aoqi@0 84 List<? extends Element> getEnclosedElements();
aoqi@0 85
aoqi@0 86 /**
aoqi@0 87 * Returns the <i>nesting kind</i> of this type element.
aoqi@0 88 *
aoqi@0 89 * @return the nesting kind of this type element
aoqi@0 90 */
aoqi@0 91 NestingKind getNestingKind();
aoqi@0 92
aoqi@0 93 /**
aoqi@0 94 * Returns the fully qualified name of this type element.
aoqi@0 95 * More precisely, it returns the <i>canonical</i> name.
aoqi@0 96 * For local and anonymous classes, which do not have canonical names,
aoqi@0 97 * an empty name is returned.
aoqi@0 98 *
aoqi@0 99 * <p>The name of a generic type does not include any reference
aoqi@0 100 * to its formal type parameters.
aoqi@0 101 * For example, the fully qualified name of the interface
aoqi@0 102 * {@code java.util.Set<E>} is "{@code java.util.Set}".
aoqi@0 103 * Nested types use "{@code .}" as a separator, as in
aoqi@0 104 * "{@code java.util.Map.Entry}".
aoqi@0 105 *
aoqi@0 106 * @return the fully qualified name of this class or interface, or
aoqi@0 107 * an empty name if none
aoqi@0 108 *
aoqi@0 109 * @see Elements#getBinaryName
aoqi@0 110 * @jls 6.7 Fully Qualified Names and Canonical Names
aoqi@0 111 */
aoqi@0 112 Name getQualifiedName();
aoqi@0 113
aoqi@0 114 /**
aoqi@0 115 * Returns the simple name of this type element.
aoqi@0 116 *
aoqi@0 117 * For an anonymous class, an empty name is returned.
aoqi@0 118 *
aoqi@0 119 * @return the simple name of this class or interface,
aoqi@0 120 * an empty name for an anonymous class
aoqi@0 121 *
aoqi@0 122 */
aoqi@0 123 @Override
aoqi@0 124 Name getSimpleName();
aoqi@0 125
aoqi@0 126 /**
aoqi@0 127 * Returns the direct superclass of this type element.
aoqi@0 128 * If this type element represents an interface or the class
aoqi@0 129 * {@code java.lang.Object}, then a {@link NoType}
aoqi@0 130 * with kind {@link TypeKind#NONE NONE} is returned.
aoqi@0 131 *
aoqi@0 132 * @return the direct superclass, or a {@code NoType} if there is none
aoqi@0 133 */
aoqi@0 134 TypeMirror getSuperclass();
aoqi@0 135
aoqi@0 136 /**
aoqi@0 137 * Returns the interface types directly implemented by this class
aoqi@0 138 * or extended by this interface.
aoqi@0 139 *
aoqi@0 140 * @return the interface types directly implemented by this class
aoqi@0 141 * or extended by this interface, or an empty list if there are none
aoqi@0 142 */
aoqi@0 143 List<? extends TypeMirror> getInterfaces();
aoqi@0 144
aoqi@0 145 /**
aoqi@0 146 * Returns the formal type parameters of this type element
aoqi@0 147 * in declaration order.
aoqi@0 148 *
aoqi@0 149 * @return the formal type parameters, or an empty list
aoqi@0 150 * if there are none
aoqi@0 151 */
aoqi@0 152 List<? extends TypeParameterElement> getTypeParameters();
aoqi@0 153
aoqi@0 154 /**
aoqi@0 155 * Returns the package of a top-level type and returns the
aoqi@0 156 * immediately lexically enclosing element for a {@linkplain
aoqi@0 157 * NestingKind#isNested nested} type.
aoqi@0 158 *
aoqi@0 159 * @return the package of a top-level type, the immediately
aoqi@0 160 * lexically enclosing element for a nested type
aoqi@0 161 */
aoqi@0 162 @Override
aoqi@0 163 Element getEnclosingElement();
aoqi@0 164 }

mercurial