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

Print this page




  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);
  74 




  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  * <p>Note that methods to accommodate new language constructs could
  56  * be added in a source <em>compatible</em> way if they were added as
  57  * <em>default methods</em>.  However, default methods are only
  58  * available on Java SE 8 and higher releases and the {@code
  59  * javax.lang.model.*} packages bundled in Java SE 8 are required to
  60  * also be runnable on Java SE 7.  Therefore, default methods
  61  * <em>cannot</em> be used when extending {@code javax.lang.model.*}
  62  * to cover Java SE 8 language features.  However, default methods may
  63  * be used in subsequent revisions of the {@code javax.lang.model.*}
  64  * packages that are only required to run on Java SE 8 and higher
  65  * platform versions.
  66  *
  67  * @param <R> the return type of this visitor's methods.  Use {@link
  68  *            Void} for visitors that do not need to return results.
  69  * @param <P> the type of the additional parameter to this visitor's
  70  *            methods.  Use {@code Void} for visitors that do not need an
  71  *            additional parameter.
  72  *
  73  * @author Joseph D. Darcy
  74  * @author Scott Seligman
  75  * @author Peter von der Ah&eacute;
  76  * @since 1.6
  77  */
  78 public interface TypeVisitor<R, P> {
  79     /**
  80      * Visits a type.
  81      * @param t the type to visit
  82      * @param p a visitor-specified parameter
  83      * @return  a visitor-specified result
  84      */
  85     R visit(TypeMirror t, P p);
  86