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;
28 import java.lang.annotation.Annotation;
29 import java.util.List;
30 import javax.lang.model.element.*;
31 import javax.lang.model.util.Types;
33 /**
34 * Represents a type in the Java programming language.
35 * Types include primitive types, declared types (class and interface types),
36 * array types, type variables, and the null type.
37 * Also represented are wildcard type arguments,
38 * the signature and return types of executables,
39 * and pseudo-types corresponding to packages and to the keyword {@code void}.
40 *
41 * <p> Types should be compared using the utility methods in {@link
42 * Types}. There is no guarantee that any particular type will always
43 * be represented by the same object.
44 *
45 * <p> To implement operations based on the class of an {@code
46 * TypeMirror} object, either use a {@linkplain TypeVisitor visitor}
47 * or use the result of the {@link #getKind} method. Using {@code
48 * instanceof} is <em>not</em> necessarily a reliable idiom for
49 * determining the effective class of an object in this modeling
50 * hierarchy since an implementation may choose to have a single
51 * object implement multiple {@code TypeMirror} subinterfaces.
52 *
53 * @author Joseph D. Darcy
54 * @author Scott Seligman
55 * @author Peter von der Ahé
56 * @see Element
57 * @see Types
58 * @since 1.6
59 */
60 public interface TypeMirror extends javax.lang.model.AnnotatedConstruct {
62 /**
63 * Returns the {@code kind} of this type.
64 *
65 * @return the kind of this type
66 */
67 TypeKind getKind();
69 /**
70 * Obeys the general contract of {@link Object#equals Object.equals}.
71 * This method does not, however, indicate whether two types represent
72 * the same type.
73 * Semantic comparisons of type equality should instead use
74 * {@link Types#isSameType(TypeMirror, TypeMirror)}.
75 * The results of {@code t1.equals(t2)} and
76 * {@code Types.isSameType(t1, t2)} may differ.
77 *
78 * @param obj the object to be compared with this type
79 * @return {@code true} if the specified object is equal to this one
80 */
81 boolean equals(Object obj);
83 /**
84 * Obeys the general contract of {@link Object#hashCode Object.hashCode}.
85 *
86 * @see #equals
87 */
88 int hashCode();
90 /**
91 * Returns an informative string representation of this type. If
92 * possible, the string should be of a form suitable for
93 * representing this type in source code. Any names embedded in
94 * the result are qualified if possible.
95 *
96 * @return a string representation of this type
97 */
98 String toString();
100 /**
101 * Applies a visitor to this type.
102 *
103 * @param <R> the return type of the visitor's methods
104 * @param <P> the type of the additional parameter to the visitor's methods
105 * @param v the visitor operating on this type
106 * @param p additional parameter to the visitor
107 * @return a visitor-specified result
108 */
109 <R, P> R accept(TypeVisitor<R, P> v, P p);
110 }