Thu, 31 Aug 2017 15:17:03 +0800
merge
1 /*
2 * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
26 package javax.lang.model.type;
29 import java.util.List;
31 import javax.lang.model.element.Element;
32 import javax.lang.model.element.TypeElement;
33 import javax.lang.model.util.Types;
36 /**
37 * Represents a declared type, either a class type or an interface type.
38 * This includes parameterized types such as {@code java.util.Set<String>}
39 * as well as raw types.
40 *
41 * <p> While a {@code TypeElement} represents a class or interface
42 * <i>element</i>, a {@code DeclaredType} represents a class
43 * or interface <i>type</i>, the latter being a use
44 * (or <i>invocation</i>) of the former.
45 * See {@link TypeElement} for more on this distinction.
46 *
47 * <p> The supertypes (both class and interface types) of a declared
48 * type may be found using the {@link
49 * Types#directSupertypes(TypeMirror)} method. This returns the
50 * supertypes with any type arguments substituted in.
51 *
52 * @author Joseph D. Darcy
53 * @author Scott Seligman
54 * @author Peter von der Ahé
55 * @see TypeElement
56 * @since 1.6
57 */
58 public interface DeclaredType extends ReferenceType {
60 /**
61 * Returns the element corresponding to this type.
62 *
63 * @return the element corresponding to this type
64 */
65 Element asElement();
67 /**
68 * Returns the type of the innermost enclosing instance or a
69 * {@code NoType} of kind {@code NONE} if there is no enclosing
70 * instance. Only types corresponding to inner classes have an
71 * enclosing instance.
72 *
73 * @return a type mirror for the enclosing type
74 * @jls 8.1.3 Inner Classes and Enclosing Instances
75 * @jls 15.9.2 Determining Enclosing Instances
76 */
77 TypeMirror getEnclosingType();
79 /**
80 * Returns the actual type arguments of this type.
81 * For a type nested within a parameterized type
82 * (such as {@code Outer<String>.Inner<Number>}), only the type
83 * arguments of the innermost type are included.
84 *
85 * @return the actual type arguments of this type, or an empty list
86 * if none
87 */
88 List<? extends TypeMirror> getTypeArguments();
89 }