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 */ 25 26 package javax.lang.model.type; 27 28 import javax.lang.model.element.*; 29 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 <code>visit<i>XYZ</i></code> 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™ 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é 76 * @since 1.6 77 */ 78 public interface TypeVisitor<R, P> { 79 /** 80 * Visits a type. 81 * @param t the type to visit | 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 */ 25 26 package javax.lang.model.type; 27 28 import javax.lang.model.element.*; 29 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 <code>visit<i>Xyz</i></code> 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™ 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 were required to 60 * also be runnable on Java SE 7. Therefore, default methods 61 * were <em>not</em> 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é 76 * @since 1.6 77 */ 78 public interface TypeVisitor<R, P> { 79 /** 80 * Visits a type. 81 * @param t the type to visit |