1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/classes/javax/lang/model/element/TypeElement.java Wed Apr 27 01:34:52 2016 +0800 1.3 @@ -0,0 +1,164 @@ 1.4 +/* 1.5 + * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. Oracle designates this 1.11 + * particular file as subject to the "Classpath" exception as provided 1.12 + * by Oracle in the LICENSE file that accompanied this code. 1.13 + * 1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.17 + * version 2 for more details (a copy is included in the LICENSE file that 1.18 + * accompanied this code). 1.19 + * 1.20 + * You should have received a copy of the GNU General Public License version 1.21 + * 2 along with this work; if not, write to the Free Software Foundation, 1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.23 + * 1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.25 + * or visit www.oracle.com if you need additional information or have any 1.26 + * questions. 1.27 + */ 1.28 + 1.29 +package javax.lang.model.element; 1.30 + 1.31 +import java.util.List; 1.32 +import javax.lang.model.type.*; 1.33 +import javax.lang.model.util.*; 1.34 + 1.35 +/** 1.36 + * Represents a class or interface program element. Provides access 1.37 + * to information about the type and its members. Note that an enum 1.38 + * type is a kind of class and an annotation type is a kind of 1.39 + * interface. 1.40 + * 1.41 + * <p> <a name="ELEM_VS_TYPE"></a> 1.42 + * While a {@code TypeElement} represents a class or interface 1.43 + * <i>element</i>, a {@link DeclaredType} represents a class 1.44 + * or interface <i>type</i>, the latter being a use 1.45 + * (or <i>invocation</i>) of the former. 1.46 + * The distinction is most apparent with generic types, 1.47 + * for which a single element can define a whole 1.48 + * family of types. For example, the element 1.49 + * {@code java.util.Set} corresponds to the parameterized types 1.50 + * {@code java.util.Set<String>} and {@code java.util.Set<Number>} 1.51 + * (and many others), and to the raw type {@code java.util.Set}. 1.52 + * 1.53 + * <p> Each method of this interface that returns a list of elements 1.54 + * will return them in the order that is natural for the underlying 1.55 + * source of program information. For example, if the underlying 1.56 + * source of information is Java source code, then the elements will be 1.57 + * returned in source code order. 1.58 + * 1.59 + * @author Joseph D. Darcy 1.60 + * @author Scott Seligman 1.61 + * @author Peter von der Ahé 1.62 + * @see DeclaredType 1.63 + * @since 1.6 1.64 + */ 1.65 +public interface TypeElement extends Element, Parameterizable, QualifiedNameable { 1.66 + /** 1.67 + * Returns the fields, methods, constructors, and member types 1.68 + * that are directly declared in this class or interface. 1.69 + * 1.70 + * This includes any (implicit) default constructor and 1.71 + * the implicit {@code values} and {@code valueOf} methods of an 1.72 + * enum type. 1.73 + * 1.74 + * <p> Note that as a particular instance of the {@linkplain 1.75 + * javax.lang.model.element general accuracy requirements} and the 1.76 + * ordering behavior required of this interface, the list of 1.77 + * enclosed elements will be returned in the natural order for the 1.78 + * originating source of information about the type. For example, 1.79 + * if the information about the type is originating from a source 1.80 + * file, the elements will be returned in source code order. 1.81 + * (However, in that case the the ordering of synthesized 1.82 + * elements, such as a default constructor, is not specified.) 1.83 + * 1.84 + * @return the enclosed elements in proper order, or an empty list if none 1.85 + */ 1.86 + @Override 1.87 + List<? extends Element> getEnclosedElements(); 1.88 + 1.89 + /** 1.90 + * Returns the <i>nesting kind</i> of this type element. 1.91 + * 1.92 + * @return the nesting kind of this type element 1.93 + */ 1.94 + NestingKind getNestingKind(); 1.95 + 1.96 + /** 1.97 + * Returns the fully qualified name of this type element. 1.98 + * More precisely, it returns the <i>canonical</i> name. 1.99 + * For local and anonymous classes, which do not have canonical names, 1.100 + * an empty name is returned. 1.101 + * 1.102 + * <p>The name of a generic type does not include any reference 1.103 + * to its formal type parameters. 1.104 + * For example, the fully qualified name of the interface 1.105 + * {@code java.util.Set<E>} is "{@code java.util.Set}". 1.106 + * Nested types use "{@code .}" as a separator, as in 1.107 + * "{@code java.util.Map.Entry}". 1.108 + * 1.109 + * @return the fully qualified name of this class or interface, or 1.110 + * an empty name if none 1.111 + * 1.112 + * @see Elements#getBinaryName 1.113 + * @jls 6.7 Fully Qualified Names and Canonical Names 1.114 + */ 1.115 + Name getQualifiedName(); 1.116 + 1.117 + /** 1.118 + * Returns the simple name of this type element. 1.119 + * 1.120 + * For an anonymous class, an empty name is returned. 1.121 + * 1.122 + * @return the simple name of this class or interface, 1.123 + * an empty name for an anonymous class 1.124 + * 1.125 + */ 1.126 + @Override 1.127 + Name getSimpleName(); 1.128 + 1.129 + /** 1.130 + * Returns the direct superclass of this type element. 1.131 + * If this type element represents an interface or the class 1.132 + * {@code java.lang.Object}, then a {@link NoType} 1.133 + * with kind {@link TypeKind#NONE NONE} is returned. 1.134 + * 1.135 + * @return the direct superclass, or a {@code NoType} if there is none 1.136 + */ 1.137 + TypeMirror getSuperclass(); 1.138 + 1.139 + /** 1.140 + * Returns the interface types directly implemented by this class 1.141 + * or extended by this interface. 1.142 + * 1.143 + * @return the interface types directly implemented by this class 1.144 + * or extended by this interface, or an empty list if there are none 1.145 + */ 1.146 + List<? extends TypeMirror> getInterfaces(); 1.147 + 1.148 + /** 1.149 + * Returns the formal type parameters of this type element 1.150 + * in declaration order. 1.151 + * 1.152 + * @return the formal type parameters, or an empty list 1.153 + * if there are none 1.154 + */ 1.155 + List<? extends TypeParameterElement> getTypeParameters(); 1.156 + 1.157 + /** 1.158 + * Returns the package of a top-level type and returns the 1.159 + * immediately lexically enclosing element for a {@linkplain 1.160 + * NestingKind#isNested nested} type. 1.161 + * 1.162 + * @return the package of a top-level type, the immediately 1.163 + * lexically enclosing element for a nested type 1.164 + */ 1.165 + @Override 1.166 + Element getEnclosingElement(); 1.167 +}