Path: blob/master/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner8.java
41161 views
/*1* Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.lang.model.util;2627import javax.lang.model.element.*;28import javax.annotation.processing.SupportedSourceVersion;29import javax.lang.model.SourceVersion;30import static javax.lang.model.SourceVersion.*;313233/**34* A scanning visitor of program elements with default behavior35* appropriate for the {@link SourceVersion#RELEASE_8 RELEASE_8}36* source version. The <code>visit<i>Xyz</i></code> methods in this37* class scan their component elements by calling {@code scan} on38* their {@linkplain Element#getEnclosedElements enclosed elements},39* {@linkplain ExecutableElement#getParameters parameters}, etc., as40* indicated in the individual method specifications. A subclass can41* control the order elements are visited by overriding the42* <code>visit<i>Xyz</i></code> methods. Note that clients of a scanner43* may get the desired behavior be invoking {@code v.scan(e, p)} rather44* than {@code v.visit(e, p)} on the root objects of interest.45*46* <p>When a subclass overrides a <code>visit<i>Xyz</i></code> method, the47* new method can cause the enclosed elements to be scanned in the48* default way by calling <code>super.visit<i>Xyz</i></code>. In this49* fashion, the concrete visitor can control the ordering of traversal50* over the component elements with respect to the additional51* processing; for example, consistently calling52* <code>super.visit<i>Xyz</i></code> at the start of the overridden53* methods will yield a preorder traversal, etc. If the component54* elements should be traversed in some other order, instead of55* calling <code>super.visit<i>Xyz</i></code>, an overriding visit method56* should call {@code scan} with the elements in the desired order.57*58* @apiNote59* Methods in this class may be overridden subject to their general60* contract.61*62* @param <R> the return type of this visitor's methods. Use {@link63* Void} for visitors that do not need to return results.64* @param <P> the type of the additional parameter to this visitor's65* methods. Use {@code Void} for visitors that do not need an66* additional parameter.67*68* @see <a href="ElementScanner6.html#note_for_subclasses"><strong>Compatibility note for subclasses</strong></a>69* @see ElementScanner670* @see ElementScanner771* @see ElementScanner972* @see ElementScanner1473* @since 1.874*/75@SupportedSourceVersion(RELEASE_8)76public class ElementScanner8<R, P> extends ElementScanner7<R, P> {77/**78* Constructor for concrete subclasses; uses {@code null} for the79* default value.80*/81@SuppressWarnings("deprecation") // Superclass constructor deprecated82protected ElementScanner8(){83super(null);84}8586/**87* Constructor for concrete subclasses; uses the argument for the88* default value.89*90* @param defaultValue the default value91*/92@SuppressWarnings("deprecation") // Superclass constructor deprecated93protected ElementScanner8(R defaultValue){94super(defaultValue);95}96}979899