1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/classes/javax/lang/model/util/ElementKindVisitor8.java Tue Jul 05 16:37:24 2011 -0700 1.3 @@ -0,0 +1,98 @@ 1.4 +/* 1.5 + * Copyright (c) 2011 Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. Oracle designates this 1.11 + * particular file as subject to the "Classpath" exception as provided 1.12 + * by Oracle in the LICENSE file that accompanied this code. 1.13 + * 1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.17 + * version 2 for more details (a copy is included in the LICENSE file that 1.18 + * accompanied this code). 1.19 + * 1.20 + * You should have received a copy of the GNU General Public License version 1.21 + * 2 along with this work; if not, write to the Free Software Foundation, 1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.23 + * 1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.25 + * or visit www.oracle.com if you need additional information or have any 1.26 + * questions. 1.27 + */ 1.28 + 1.29 +package javax.lang.model.util; 1.30 + 1.31 +import javax.lang.model.element.*; 1.32 +import static javax.lang.model.element.ElementKind.*; 1.33 +import javax.annotation.processing.SupportedSourceVersion; 1.34 +import static javax.lang.model.SourceVersion.*; 1.35 +import javax.lang.model.SourceVersion; 1.36 + 1.37 +/** 1.38 + * A visitor of program elements based on their {@linkplain 1.39 + * ElementKind kind} with default behavior appropriate for the {@link 1.40 + * SourceVersion#RELEASE_8 RELEASE_8} source version. For {@linkplain 1.41 + * Element elements} <tt><i>XYZ</i></tt> that may have more than one 1.42 + * kind, the <tt>visit<i>XYZ</i></tt> methods in this class delegate 1.43 + * to the <tt>visit<i>XYZKind</i></tt> method corresponding to the 1.44 + * first argument's kind. The <tt>visit<i>XYZKind</i></tt> methods 1.45 + * call {@link #defaultAction defaultAction}, passing their arguments 1.46 + * to {@code defaultAction}'s corresponding parameters. 1.47 + * 1.48 + * <p> Methods in this class may be overridden subject to their 1.49 + * general contract. Note that annotating methods in concrete 1.50 + * subclasses with {@link java.lang.Override @Override} will help 1.51 + * ensure that methods are overridden as intended. 1.52 + * 1.53 + * <p> <b>WARNING:</b> The {@code ElementVisitor} interface 1.54 + * implemented by this class may have methods added to it or the 1.55 + * {@code ElementKind} {@code enum} used in this case may have 1.56 + * constants added to it in the future to accommodate new, currently 1.57 + * unknown, language structures added to future versions of the 1.58 + * Java™ programming language. Therefore, methods whose names 1.59 + * begin with {@code "visit"} may be added to this class in the 1.60 + * future; to avoid incompatibilities, classes which extend this class 1.61 + * should not declare any instance methods with names beginning with 1.62 + * {@code "visit"}. 1.63 + * 1.64 + * <p>When such a new visit method is added, the default 1.65 + * implementation in this class will be to call the {@link 1.66 + * #visitUnknown visitUnknown} method. A new abstract element kind 1.67 + * visitor class will also be introduced to correspond to the new 1.68 + * language level; this visitor will have different default behavior 1.69 + * for the visit method in question. When the new visitor is 1.70 + * introduced, all or portions of this visitor may be deprecated. 1.71 + * 1.72 + * @param <R> the return type of this visitor's methods. Use {@link 1.73 + * Void} for visitors that do not need to return results. 1.74 + * @param <P> the type of the additional parameter to this visitor's 1.75 + * methods. Use {@code Void} for visitors that do not need an 1.76 + * additional parameter. 1.77 + * 1.78 + * @see ElementKindVisitor6 1.79 + * @see ElementKindVisitor7 1.80 + * @since 1.8 1.81 + */ 1.82 +@SupportedSourceVersion(RELEASE_8) 1.83 +public class ElementKindVisitor8<R, P> extends ElementKindVisitor7<R, P> { 1.84 + /** 1.85 + * Constructor for concrete subclasses; uses {@code null} for the 1.86 + * default value. 1.87 + */ 1.88 + protected ElementKindVisitor8() { 1.89 + super(null); 1.90 + } 1.91 + 1.92 + /** 1.93 + * Constructor for concrete subclasses; uses the argument for the 1.94 + * default value. 1.95 + * 1.96 + * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} 1.97 + */ 1.98 + protected ElementKindVisitor8(R defaultValue) { 1.99 + super(defaultValue); 1.100 + } 1.101 +}