aoqi@0: /* aoqi@0: * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. Oracle designates this aoqi@0: * particular file as subject to the "Classpath" exception as provided aoqi@0: * by Oracle in the LICENSE file that accompanied this code. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: */ aoqi@0: aoqi@0: package javax.lang.model.element; aoqi@0: aoqi@0: import java.util.List; aoqi@0: import javax.lang.model.type.*; aoqi@0: import javax.lang.model.util.*; aoqi@0: aoqi@0: /** aoqi@0: * Represents a class or interface program element. Provides access aoqi@0: * to information about the type and its members. Note that an enum aoqi@0: * type is a kind of class and an annotation type is a kind of aoqi@0: * interface. aoqi@0: * aoqi@0: *

aoqi@0: * While a {@code TypeElement} represents a class or interface aoqi@0: * element, a {@link DeclaredType} represents a class aoqi@0: * or interface type, the latter being a use aoqi@0: * (or invocation) of the former. aoqi@0: * The distinction is most apparent with generic types, aoqi@0: * for which a single element can define a whole aoqi@0: * family of types. For example, the element aoqi@0: * {@code java.util.Set} corresponds to the parameterized types aoqi@0: * {@code java.util.Set} and {@code java.util.Set} aoqi@0: * (and many others), and to the raw type {@code java.util.Set}. aoqi@0: * aoqi@0: *

Each method of this interface that returns a list of elements aoqi@0: * will return them in the order that is natural for the underlying aoqi@0: * source of program information. For example, if the underlying aoqi@0: * source of information is Java source code, then the elements will be aoqi@0: * returned in source code order. aoqi@0: * aoqi@0: * @author Joseph D. Darcy aoqi@0: * @author Scott Seligman aoqi@0: * @author Peter von der Ahé aoqi@0: * @see DeclaredType aoqi@0: * @since 1.6 aoqi@0: */ aoqi@0: public interface TypeElement extends Element, Parameterizable, QualifiedNameable { aoqi@0: /** aoqi@0: * Returns the fields, methods, constructors, and member types aoqi@0: * that are directly declared in this class or interface. aoqi@0: * aoqi@0: * This includes any (implicit) default constructor and aoqi@0: * the implicit {@code values} and {@code valueOf} methods of an aoqi@0: * enum type. aoqi@0: * aoqi@0: *

Note that as a particular instance of the {@linkplain aoqi@0: * javax.lang.model.element general accuracy requirements} and the aoqi@0: * ordering behavior required of this interface, the list of aoqi@0: * enclosed elements will be returned in the natural order for the aoqi@0: * originating source of information about the type. For example, aoqi@0: * if the information about the type is originating from a source aoqi@0: * file, the elements will be returned in source code order. aoqi@0: * (However, in that case the the ordering of synthesized aoqi@0: * elements, such as a default constructor, is not specified.) aoqi@0: * aoqi@0: * @return the enclosed elements in proper order, or an empty list if none aoqi@0: */ aoqi@0: @Override aoqi@0: List getEnclosedElements(); aoqi@0: aoqi@0: /** aoqi@0: * Returns the nesting kind of this type element. aoqi@0: * aoqi@0: * @return the nesting kind of this type element aoqi@0: */ aoqi@0: NestingKind getNestingKind(); aoqi@0: aoqi@0: /** aoqi@0: * Returns the fully qualified name of this type element. aoqi@0: * More precisely, it returns the canonical name. aoqi@0: * For local and anonymous classes, which do not have canonical names, aoqi@0: * an empty name is returned. aoqi@0: * aoqi@0: *

The name of a generic type does not include any reference aoqi@0: * to its formal type parameters. aoqi@0: * For example, the fully qualified name of the interface aoqi@0: * {@code java.util.Set} is "{@code java.util.Set}". aoqi@0: * Nested types use "{@code .}" as a separator, as in aoqi@0: * "{@code java.util.Map.Entry}". aoqi@0: * aoqi@0: * @return the fully qualified name of this class or interface, or aoqi@0: * an empty name if none aoqi@0: * aoqi@0: * @see Elements#getBinaryName aoqi@0: * @jls 6.7 Fully Qualified Names and Canonical Names aoqi@0: */ aoqi@0: Name getQualifiedName(); aoqi@0: aoqi@0: /** aoqi@0: * Returns the simple name of this type element. aoqi@0: * aoqi@0: * For an anonymous class, an empty name is returned. aoqi@0: * aoqi@0: * @return the simple name of this class or interface, aoqi@0: * an empty name for an anonymous class aoqi@0: * aoqi@0: */ aoqi@0: @Override aoqi@0: Name getSimpleName(); aoqi@0: aoqi@0: /** aoqi@0: * Returns the direct superclass of this type element. aoqi@0: * If this type element represents an interface or the class aoqi@0: * {@code java.lang.Object}, then a {@link NoType} aoqi@0: * with kind {@link TypeKind#NONE NONE} is returned. aoqi@0: * aoqi@0: * @return the direct superclass, or a {@code NoType} if there is none aoqi@0: */ aoqi@0: TypeMirror getSuperclass(); aoqi@0: aoqi@0: /** aoqi@0: * Returns the interface types directly implemented by this class aoqi@0: * or extended by this interface. aoqi@0: * aoqi@0: * @return the interface types directly implemented by this class aoqi@0: * or extended by this interface, or an empty list if there are none aoqi@0: */ aoqi@0: List getInterfaces(); aoqi@0: aoqi@0: /** aoqi@0: * Returns the formal type parameters of this type element aoqi@0: * in declaration order. aoqi@0: * aoqi@0: * @return the formal type parameters, or an empty list aoqi@0: * if there are none aoqi@0: */ aoqi@0: List getTypeParameters(); aoqi@0: aoqi@0: /** aoqi@0: * Returns the package of a top-level type and returns the aoqi@0: * immediately lexically enclosing element for a {@linkplain aoqi@0: * NestingKind#isNested nested} type. aoqi@0: * aoqi@0: * @return the package of a top-level type, the immediately aoqi@0: * lexically enclosing element for a nested type aoqi@0: */ aoqi@0: @Override aoqi@0: Element getEnclosingElement(); aoqi@0: }