< prev index next >

src/java.compiler/share/classes/javax/lang/model/util/ElementScanner14.java

Print this page




  14  * version 2 for more details (a copy is included in the LICENSE file that
  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.util;
  27 
  28 import javax.lang.model.element.*;
  29 import javax.annotation.processing.SupportedSourceVersion;
  30 import javax.lang.model.SourceVersion;
  31 import static javax.lang.model.SourceVersion.*;
  32 
  33 /**








  34  * A scanning visitor of program elements with default behavior
  35  * appropriate for the {@link SourceVersion#RELEASE_14 RELEASE_14}
  36  * source version.
  37  *
  38  * The <code>visit<i>Xyz</i></code> methods in this
  39  * class scan their component elements by calling {@code scan} on
  40  * their {@linkplain Element#getEnclosedElements enclosed elements},
  41  * {@linkplain ExecutableElement#getParameters parameters}, etc., as
  42  * indicated in the individual method specifications.  A subclass can
  43  * control the order elements are visited by overriding the
  44  * <code>visit<i>Xyz</i></code> methods.  Note that clients of a scanner
  45  * may get the desired behavior be invoking {@code v.scan(e, p)} rather
  46  * than {@code v.visit(e, p)} on the root objects of interest.
  47  *
  48  * <p>When a subclass overrides a <code>visit<i>Xyz</i></code> method, the
  49  * new method can cause the enclosed elements to be scanned in the
  50  * default way by calling <code>super.visit<i>Xyz</i></code>.  In this
  51  * fashion, the concrete visitor can control the ordering of traversal
  52  * over the component elements with respect to the additional
  53  * processing; for example, consistently calling


  73  *
  74  * <p>When such a new visit method is added, the default
  75  * implementation in this class will be to call the {@link
  76  * #visitUnknown visitUnknown} method.  A new element scanner visitor
  77  * class will also be introduced to correspond to the new language
  78  * level; this visitor will have different default behavior for the
  79  * visit method in question.  When the new visitor is introduced, all
  80  * or portions of this visitor may be deprecated.
  81  *
  82  * @param <R> the return type of this visitor's methods.  Use {@link
  83  *            Void} for visitors that do not need to return results.
  84  * @param <P> the type of the additional parameter to this visitor's
  85  *            methods.  Use {@code Void} for visitors that do not need an
  86  *            additional parameter.
  87  *
  88  * @see ElementScanner6
  89  * @see ElementScanner7
  90  * @see ElementScanner8
  91  * @see ElementScanner9
  92  * @since 14
  93  * @deprecated This class is part of a preview feature and may be removed
  94  * if the preview feature is removed.
  95  */
  96 @Deprecated(forRemoval=true, since="14")
  97 @SuppressWarnings("removal")

  98 @SupportedSourceVersion(RELEASE_14)
  99 public class ElementScanner14<R, P> extends ElementScanner9<R, P> {
 100     /**
 101      * Constructor for concrete subclasses; uses {@code null} for the
 102      * default value.
 103      */
 104     protected ElementScanner14(){
 105         super(null);
 106     }
 107 
 108     /**
 109      * Constructor for concrete subclasses; uses the argument for the
 110      * default value.
 111      *
 112      * @param defaultValue the default value
 113      */
 114     protected ElementScanner14(R defaultValue){
 115         super(defaultValue);
 116     }
 117 


  14  * version 2 for more details (a copy is included in the LICENSE file that
  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.util;
  27 
  28 import javax.lang.model.element.*;
  29 import javax.annotation.processing.SupportedSourceVersion;
  30 import javax.lang.model.SourceVersion;
  31 import static javax.lang.model.SourceVersion.*;
  32 
  33 /**
  34  * {@preview Associated with records, a preview feature of the Java language.
  35  *
  36  *           This class is associated with <i>records</i>, a preview
  37  *           feature of the Java language. Programs can only use this
  38  *           method when preview features are enabled. Preview features
  39  *           may be removed in a future release, or upgraded to permanent
  40  *           features of the Java language.}
  41  *
  42  * A scanning visitor of program elements with default behavior
  43  * appropriate for the {@link SourceVersion#RELEASE_14 RELEASE_14}
  44  * source version.
  45  *
  46  * The <code>visit<i>Xyz</i></code> methods in this
  47  * class scan their component elements by calling {@code scan} on
  48  * their {@linkplain Element#getEnclosedElements enclosed elements},
  49  * {@linkplain ExecutableElement#getParameters parameters}, etc., as
  50  * indicated in the individual method specifications.  A subclass can
  51  * control the order elements are visited by overriding the
  52  * <code>visit<i>Xyz</i></code> methods.  Note that clients of a scanner
  53  * may get the desired behavior be invoking {@code v.scan(e, p)} rather
  54  * than {@code v.visit(e, p)} on the root objects of interest.
  55  *
  56  * <p>When a subclass overrides a <code>visit<i>Xyz</i></code> method, the
  57  * new method can cause the enclosed elements to be scanned in the
  58  * default way by calling <code>super.visit<i>Xyz</i></code>.  In this
  59  * fashion, the concrete visitor can control the ordering of traversal
  60  * over the component elements with respect to the additional
  61  * processing; for example, consistently calling


  81  *
  82  * <p>When such a new visit method is added, the default
  83  * implementation in this class will be to call the {@link
  84  * #visitUnknown visitUnknown} method.  A new element scanner visitor
  85  * class will also be introduced to correspond to the new language
  86  * level; this visitor will have different default behavior for the
  87  * visit method in question.  When the new visitor is introduced, all
  88  * or portions of this visitor may be deprecated.
  89  *
  90  * @param <R> the return type of this visitor's methods.  Use {@link
  91  *            Void} for visitors that do not need to return results.
  92  * @param <P> the type of the additional parameter to this visitor's
  93  *            methods.  Use {@code Void} for visitors that do not need an
  94  *            additional parameter.
  95  *
  96  * @see ElementScanner6
  97  * @see ElementScanner7
  98  * @see ElementScanner8
  99  * @see ElementScanner9
 100  * @since 14


 101  */
 102 @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
 103                              essentialAPI=false)
 104 @SuppressWarnings("preview")
 105 @SupportedSourceVersion(RELEASE_14)
 106 public class ElementScanner14<R, P> extends ElementScanner9<R, P> {
 107     /**
 108      * Constructor for concrete subclasses; uses {@code null} for the
 109      * default value.
 110      */
 111     protected ElementScanner14(){
 112         super(null);
 113     }
 114 
 115     /**
 116      * Constructor for concrete subclasses; uses the argument for the
 117      * default value.
 118      *
 119      * @param defaultValue the default value
 120      */
 121     protected ElementScanner14(R defaultValue){
 122         super(defaultValue);
 123     }
 124 
< prev index next >