src/share/classes/javax/lang/model/type/TypeMirror.java

Fri, 06 Feb 2009 12:49:48 -0800

author
darcy
date
Fri, 06 Feb 2009 12:49:48 -0800
changeset 216
58fcba61a77d
parent 1
9a66ca7c79fa
child 554
9d9f26857129
permissions
-rw-r--r--

6794071: Provide exception superclass for UnknownFooExceptions
Reviewed-by: jjg

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

mercurial