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

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

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

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

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