Fri, 06 Feb 2009 12:49:48 -0800
6794071: Provide exception superclass for UnknownFooExceptions
Reviewed-by: jjg
duke@1 | 1 | /* |
duke@1 | 2 | * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. |
duke@1 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@1 | 4 | * |
duke@1 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@1 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@1 | 7 | * published by the Free Software Foundation. Sun designates this |
duke@1 | 8 | * particular file as subject to the "Classpath" exception as provided |
duke@1 | 9 | * by Sun in the LICENSE file that accompanied this code. |
duke@1 | 10 | * |
duke@1 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@1 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@1 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@1 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@1 | 15 | * accompanied this code). |
duke@1 | 16 | * |
duke@1 | 17 | * You should have received a copy of the GNU General Public License version |
duke@1 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@1 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@1 | 20 | * |
duke@1 | 21 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
duke@1 | 22 | * CA 95054 USA or visit www.sun.com if you need additional information or |
duke@1 | 23 | * have any questions. |
duke@1 | 24 | */ |
duke@1 | 25 | |
duke@1 | 26 | package javax.lang.model.type; |
duke@1 | 27 | |
duke@1 | 28 | import javax.lang.model.element.*; |
duke@1 | 29 | import javax.lang.model.util.Types; |
duke@1 | 30 | |
duke@1 | 31 | /** |
duke@1 | 32 | * Represents a type in the Java programming language. |
duke@1 | 33 | * Types include primitive types, declared types (class and interface types), |
duke@1 | 34 | * array types, type variables, and the null type. |
duke@1 | 35 | * Also represented are wildcard type arguments, |
duke@1 | 36 | * the signature and return types of executables, |
duke@1 | 37 | * and pseudo-types corresponding to packages and to the keyword {@code void}. |
duke@1 | 38 | * |
duke@1 | 39 | * <p> Types should be compared using the utility methods in {@link |
duke@1 | 40 | * Types}. There is no guarantee that any particular type will always |
duke@1 | 41 | * be represented by the same object. |
duke@1 | 42 | * |
duke@1 | 43 | * <p> To implement operations based on the class of an {@code |
duke@1 | 44 | * TypeMirror} object, either use a {@linkplain TypeVisitor visitor} |
duke@1 | 45 | * or use the result of the {@link #getKind} method. Using {@code |
duke@1 | 46 | * instanceof} is <em>not</em> necessarily a reliable idiom for |
duke@1 | 47 | * determining the effective class of an object in this modeling |
duke@1 | 48 | * hierarchy since an implementation may choose to have a single |
duke@1 | 49 | * object implement multiple {@code TypeMirror} subinterfaces. |
duke@1 | 50 | * |
duke@1 | 51 | * @author Joseph D. Darcy |
duke@1 | 52 | * @author Scott Seligman |
duke@1 | 53 | * @author Peter von der Ahé |
duke@1 | 54 | * @see Element |
duke@1 | 55 | * @see Types |
duke@1 | 56 | * @since 1.6 |
duke@1 | 57 | */ |
duke@1 | 58 | public interface TypeMirror { |
duke@1 | 59 | |
duke@1 | 60 | /** |
duke@1 | 61 | * Returns the {@code kind} of this type. |
duke@1 | 62 | * |
duke@1 | 63 | * @return the kind of this type |
duke@1 | 64 | */ |
duke@1 | 65 | TypeKind getKind(); |
duke@1 | 66 | |
duke@1 | 67 | /** |
duke@1 | 68 | * Obeys the general contract of {@link Object#equals Object.equals}. |
duke@1 | 69 | * This method does not, however, indicate whether two types represent |
duke@1 | 70 | * the same type. |
duke@1 | 71 | * Semantic comparisons of type equality should instead use |
duke@1 | 72 | * {@link Types#isSameType(TypeMirror, TypeMirror)}. |
duke@1 | 73 | * The results of {@code t1.equals(t2)} and |
duke@1 | 74 | * {@code Types.isSameType(t1, t2)} may differ. |
duke@1 | 75 | * |
duke@1 | 76 | * @param obj the object to be compared with this type |
duke@1 | 77 | * @return {@code true} if the specified object is equal to this one |
duke@1 | 78 | */ |
duke@1 | 79 | boolean equals(Object obj); |
duke@1 | 80 | |
duke@1 | 81 | /** |
duke@1 | 82 | * Obeys the general contract of {@link Object#hashCode Object.hashCode}. |
duke@1 | 83 | * |
duke@1 | 84 | * @see #equals |
duke@1 | 85 | */ |
duke@1 | 86 | int hashCode(); |
duke@1 | 87 | |
duke@1 | 88 | /** |
duke@1 | 89 | * Returns an informative string representation of this type. If |
duke@1 | 90 | * possible, the string should be of a form suitable for |
duke@1 | 91 | * representing this type in source code. Any names embedded in |
duke@1 | 92 | * the result are qualified if possible. |
duke@1 | 93 | * |
duke@1 | 94 | * @return a string representation of this type |
duke@1 | 95 | */ |
duke@1 | 96 | String toString(); |
duke@1 | 97 | |
duke@1 | 98 | /** |
duke@1 | 99 | * Applies a visitor to this type. |
duke@1 | 100 | * |
duke@1 | 101 | * @param <R> the return type of the visitor's methods |
duke@1 | 102 | * @param <P> the type of the additional parameter to the visitor's methods |
duke@1 | 103 | * @param v the visitor operating on this type |
duke@1 | 104 | * @param p additional parameter to the visitor |
duke@1 | 105 | * @return a visitor-specified result |
duke@1 | 106 | */ |
duke@1 | 107 | <R, P> R accept(TypeVisitor<R, P> v, P p); |
duke@1 | 108 | } |