KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > lang > model > type > TypeMirror


1 /*
2  * @(#)TypeMirror.java 1.6 06/08/03
3  *
4  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package javax.lang.model.type;
9
10 import javax.lang.model.element.*;
11 import javax.lang.model.util.Types;
12
13 /**
14  * Represents a type in the Java programming language.
15  * Types include primitive types, declared types (class and interface types),
16  * array types, type variables, and the null type.
17  * Also represented are wildcard type arguments,
18  * the signature and return types of executables,
19  * and pseudo-types corresponding to packages and to the keyword {@code void}.
20  *
21  * <p> Types should be compared using the utility methods in {@link
22  * Types}. There is no guarantee that any particular type will always
23  * be represented by the same object.
24  *
25  * <p> To implement operations based on the class of an {@code
26  * TypeMirror} object, either use a {@linkplain TypeVisitor visitor}
27  * or use the result of the {@link #getKind} method. Using {@code
28  * instanceof} is <em>not</em> necessarily a reliable idiom for
29  * determining the effective class of an object in this modeling
30  * hierarchy since an implementation may choose to have a single
31  * object implement multiple {@code TypeMirror} subinterfaces.
32  *
33  * @author Joseph D. Darcy
34  * @author Scott Seligman
35  * @author Peter von der Ah&eacute;
36  * @version 1.6 06/08/03
37  * @see Element
38  * @see Types
39  * @since 1.6
40  */

41 public interface TypeMirror {
42
43     /**
44      * Returns the {@code kind} of this type.
45      *
46      * @return the kind of this type
47      */

48     TypeKind getKind();
49
50     /**
51      * Obeys the general contract of {@link Object#equals Object.equals}.
52      * This method does not, however, indicate whether two types represent
53      * the same type.
54      * Semantic comparisons of type equality should instead use
55      * {@link Types#isSameType(TypeMirror, TypeMirror)}.
56      * The results of {@code t1.equals(t2)} and
57      * {@code Types.isSameType(t1, t2)} may differ.
58      *
59      * @param obj the object to be compared with this type
60      * @return {@code true} if the specified object is equal to this one
61      */

62     boolean equals(Object JavaDoc obj);
63
64     /**
65      * Obeys the general contract of {@link Object#hashCode Object.hashCode}.
66      *
67      * @see #equals
68      */

69     int hashCode();
70
71     /**
72      * Returns an informative string representation of this type. If
73      * possible, the string should be of a form suitable for
74      * representing this type in source code. Any names embedded in
75      * the result are qualified if possible.
76      *
77      * @return a string representation of this type
78      */

79     String JavaDoc toString();
80
81     /**
82      * Applies a visitor to this type.
83      *
84      * @param <R> the return type of the visitor's methods
85      * @param <P> the type of the additional parameter to the visitor's methods
86      * @param v the visitor operating on this type
87      * @param p additional parameter to the visitor
88      * @return a visitor-specified result
89      */

90     <R, P> R accept(TypeVisitor<R, P> v, P p);
91 }
92
Popular Tags