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

Wed, 06 Apr 2011 19:30:57 -0700

author
darcy
date
Wed, 06 Apr 2011 19:30:57 -0700
changeset 969
8cc5b440fdde
parent 851
cad51b6eb7a6
child 1436
f6f1fd261f57
permissions
-rw-r--r--

7033809: Rename "disjunctive" to "union" in javax.lang.model
Reviewed-by: mcimadamore, jjg

     1 /*
     2  * Copyright (c) 2005, 2011, 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 javax.lang.model.element.*;
    30 /**
    31  * A visitor of types, in the style of the
    32  * visitor design pattern.  Classes implementing this
    33  * interface are used to operate on a type when the kind of
    34  * type is unknown at compile time.  When a visitor is passed to a
    35  * type's {@link TypeMirror#accept accept} method, the <tt>visit<i>XYZ</i></tt>
    36  * method most applicable to that type is invoked.
    37  *
    38  * <p> Classes implementing this interface may or may not throw a
    39  * {@code NullPointerException} if the additional parameter {@code p}
    40  * is {@code null}; see documentation of the implementing class for
    41  * details.
    42  *
    43  * <p> <b>WARNING:</b> It is possible that methods will be added to
    44  * this interface to accommodate new, currently unknown, language
    45  * structures added to future versions of the Java&trade; programming
    46  * language.  Therefore, visitor classes directly implementing this
    47  * interface may be source incompatible with future versions of the
    48  * platform.  To avoid this source incompatibility, visitor
    49  * implementations are encouraged to instead extend the appropriate
    50  * abstract visitor class that implements this interface.  However, an
    51  * API should generally use this visitor interface as the type for
    52  * parameters, return type, etc. rather than one of the abstract
    53  * classes.
    54  *
    55  * @param <R> the return type of this visitor's methods.  Use {@link
    56  *            Void} for visitors that do not need to return results.
    57  * @param <P> the type of the additional parameter to this visitor's
    58  *            methods.  Use {@code Void} for visitors that do not need an
    59  *            additional parameter.
    60  *
    61  * @author Joseph D. Darcy
    62  * @author Scott Seligman
    63  * @author Peter von der Ah&eacute;
    64  * @since 1.6
    65  */
    66 public interface TypeVisitor<R, P> {
    67     /**
    68      * Visits a type.
    69      * @param t the type to visit
    70      * @param p a visitor-specified parameter
    71      * @return  a visitor-specified result
    72      */
    73     R visit(TypeMirror t, P p);
    75     /**
    76      * A convenience method equivalent to {@code v.visit(t, null)}.
    77      * @param t the element to visit
    78      * @return  a visitor-specified result
    79      */
    80     R visit(TypeMirror t);
    82     /**
    83      * Visits a primitive type.
    84      * @param t the type to visit
    85      * @param p a visitor-specified parameter
    86      * @return  a visitor-specified result
    87      */
    88     R visitPrimitive(PrimitiveType t, P p);
    90     /**
    91      * Visits the null type.
    92      * @param t the type to visit
    93      * @param p a visitor-specified parameter
    94      * @return  a visitor-specified result
    95      */
    96     R visitNull(NullType t, P p);
    98     /**
    99      * Visits an array type.
   100      * @param t the type to visit
   101      * @param p a visitor-specified parameter
   102      * @return  a visitor-specified result
   103      */
   104     R visitArray(ArrayType t, P p);
   106     /**
   107      * Visits a declared type.
   108      * @param t the type to visit
   109      * @param p a visitor-specified parameter
   110      * @return  a visitor-specified result
   111      */
   112     R visitDeclared(DeclaredType t, P p);
   114     /**
   115      * Visits an error type.
   116      * @param t the type to visit
   117      * @param p a visitor-specified parameter
   118      * @return  a visitor-specified result
   119      */
   120     R visitError(ErrorType t, P p);
   122     /**
   123      * Visits a type variable.
   124      * @param t the type to visit
   125      * @param p a visitor-specified parameter
   126      * @return  a visitor-specified result
   127      */
   128     R visitTypeVariable(TypeVariable t, P p);
   130     /**
   131      * Visits a wildcard type.
   132      * @param t the type to visit
   133      * @param p a visitor-specified parameter
   134      * @return  a visitor-specified result
   135      */
   136     R visitWildcard(WildcardType t, P p);
   138     /**
   139      * Visits an executable type.
   140      * @param t the type to visit
   141      * @param p a visitor-specified parameter
   142      * @return  a visitor-specified result
   143      */
   144     R visitExecutable(ExecutableType t, P p);
   146     /**
   147      * Visits a {@link NoType} instance.
   148      * @param t the type to visit
   149      * @param p a visitor-specified parameter
   150      * @return  a visitor-specified result
   151      */
   152     R visitNoType(NoType t, P p);
   154     /**
   155      * Visits an unknown kind of type.
   156      * This can occur if the language evolves and new kinds
   157      * of types are added to the {@code TypeMirror} hierarchy.
   158      * @param t the type to visit
   159      * @param p a visitor-specified parameter
   160      * @return  a visitor-specified result
   161      * @throws UnknownTypeException
   162      *  a visitor implementation may optionally throw this exception
   163      */
   164     R visitUnknown(TypeMirror t, P p);
   166     /**
   167      * Visits a union type.
   168      *
   169      * @param t the type to visit
   170      * @param p a visitor-specified parameter
   171      * @return  a visitor-specified result
   172      * @since 1.7
   173      */
   174     R visitUnion(UnionType t, P p);
   175 }

mercurial