SimpleElementVisitor7.java revision 2571:10fc81ac75b4
11558Srgrimes/*
21558Srgrimes * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
31558Srgrimes * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
41558Srgrimes *
51558Srgrimes * This code is free software; you can redistribute it and/or modify it
61558Srgrimes * under the terms of the GNU General Public License version 2 only, as
71558Srgrimes * published by the Free Software Foundation.  Oracle designates this
81558Srgrimes * particular file as subject to the "Classpath" exception as provided
91558Srgrimes * by Oracle in the LICENSE file that accompanied this code.
101558Srgrimes *
111558Srgrimes * This code is distributed in the hope that it will be useful, but WITHOUT
121558Srgrimes * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
131558Srgrimes * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
141558Srgrimes * version 2 for more details (a copy is included in the LICENSE file that
151558Srgrimes * accompanied this code).
161558Srgrimes *
171558Srgrimes * You should have received a copy of the GNU General Public License version
181558Srgrimes * 2 along with this work; if not, write to the Free Software Foundation,
191558Srgrimes * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
201558Srgrimes *
211558Srgrimes * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
221558Srgrimes * or visit www.oracle.com if you need additional information or have any
231558Srgrimes * questions.
241558Srgrimes */
251558Srgrimes
261558Srgrimespackage javax.lang.model.util;
271558Srgrimes
281558Srgrimesimport javax.lang.model.element.*;
291558Srgrimesimport javax.annotation.processing.SupportedSourceVersion;
30114589Sobrienimport javax.lang.model.SourceVersion;
311558Srgrimesimport static javax.lang.model.SourceVersion.*;
3223675Speter
33114589Sobrien/**
3441477Sjulian * A simple visitor of program elements with default behavior
35114589Sobrien * appropriate for the {@link SourceVersion#RELEASE_7 RELEASE_7}
36114589Sobrien * source version.
371558Srgrimes *
381558Srgrimes * Visit methods corresponding to {@code RELEASE_7} and earlier
3998542Smckusick * language constructs call {@link #defaultAction defaultAction},
4074556Smckusick * passing their arguments to {@code defaultAction}'s corresponding
4123675Speter * parameters.
421558Srgrimes *
431558Srgrimes * <p> Methods in this class may be overridden subject to their
441558Srgrimes * general contract.  Note that annotating methods in concrete
4523675Speter * subclasses with {@link java.lang.Override @Override} will help
4623675Speter * ensure that methods are overridden as intended.
471558Srgrimes *
481558Srgrimes * <p> <b>WARNING:</b> The {@code ElementVisitor} interface
49217769Smckusick * implemented by this class may have methods added to it in the
5023675Speter * future to accommodate new, currently unknown, language structures
511558Srgrimes * added to future versions of the Java&trade; programming language.
521558Srgrimes * Therefore, methods whose names begin with {@code "visit"} may be
531558Srgrimes * added to this class in the future; to avoid incompatibilities,
541558Srgrimes * classes which extend this class should not declare any instance
55247212Smckusick * methods with names beginning with {@code "visit"}.
567585Sbde *
577585Sbde * <p>When such a new visit method is added, the default
5898542Smckusick * implementation in this class will be to call the {@link
591558Srgrimes * #visitUnknown visitUnknown} method.  A new simple element visitor
6098542Smckusick * class will also be introduced to correspond to the new language
6198542Smckusick * level; this visitor will have different default behavior for the
6298542Smckusick * visit method in question.  When the new visitor is introduced, all
6398542Smckusick * or portions of this visitor may be deprecated.
641558Srgrimes *
6518808Sguido * <p>Note that adding a default implementation of a new visit method
661558Srgrimes * in a visitor class will occur instead of adding a <em>default
671558Srgrimes * method</em> directly in the visitor interface since a Java SE 8
681558Srgrimes * language feature cannot be used to this version of the API since
6962668Smckusick * this version is required to be runnable on Java SE 7
701558Srgrimes * implementations.  Future versions of the API that are only required
7198542Smckusick * to run on Java SE 8 and later may take advantage of default methods
7298542Smckusick * in this situation.
731558Srgrimes *
7498542Smckusick * @param <R> the return type of this visitor's methods.  Use {@code Void}
751558Srgrimes *             for visitors that do not need to return results.
7698542Smckusick * @param <P> the type of the additional parameter to this visitor's methods.  Use {@code Void}
7798542Smckusick *              for visitors that do not need an additional parameter.
7898542Smckusick *
7998542Smckusick * @see SimpleElementVisitor6
8098542Smckusick * @see SimpleElementVisitor8
8198542Smckusick * @see SimpleElementVisitor9
8262668Smckusick * @since 1.7
8398542Smckusick */
8498542Smckusick@SuppressWarnings("deprecation") // Superclass deprecated
851558Srgrimes@SupportedSourceVersion(RELEASE_7)
861558Srgrimespublic class SimpleElementVisitor7<R, P> extends SimpleElementVisitor6<R, P> {
871558Srgrimes    /**
881558Srgrimes     * Constructor for concrete subclasses; uses {@code null} for the
8998542Smckusick     * default value.
9018808Sguido     */
9118808Sguido    protected SimpleElementVisitor7(){
9218808Sguido        super(null);
9318808Sguido    }
94221110Sdes
9518808Sguido    /**
96221110Sdes     * Constructor for concrete subclasses; uses the argument for the
9718808Sguido     * default value.
98221110Sdes     *
99134589Sscottl     * @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
10018808Sguido     */
10118808Sguido    protected SimpleElementVisitor7(R defaultValue){
10218808Sguido        super(defaultValue);
103221110Sdes    }
104221110Sdes
105221110Sdes    /**
10618808Sguido     * This implementation calls {@code defaultAction}.
1071558Srgrimes     *
10818808Sguido     * @param e {@inheritDoc}
10998542Smckusick     * @param p {@inheritDoc}
11062668Smckusick     * @return  the result of {@code defaultAction}
1111558Srgrimes     */
1121558Srgrimes    @Override
1131558Srgrimes    public R visitVariable(VariableElement e, P p) {
1141558Srgrimes        return defaultAction(e, p);
1151558Srgrimes    }
1161558Srgrimes}
1171558Srgrimes