src/share/classes/javax/lang/model/util/ElementScanner6.java

Print this page

        

@@ -86,119 +86,27 @@
  *            additional parameter.
  *
  * @author Joseph D. Darcy
  * @author Scott Seligman
  * @author Peter von der Ahé
+ *
+ * @see ElementScanner7
  * @since 1.6
  */
 @SupportedSourceVersion(RELEASE_6)
-public class ElementScanner6<R, P> extends AbstractElementVisitor6<R, P> {
-    /**
-     * The specified default value.
-     */
-    protected final R DEFAULT_VALUE;
-
+public class ElementScanner6<R, P> extends SharedElementScanner<R, P> {
     /**
      * Constructor for concrete subclasses; uses {@code null} for the
      * default value.
      */
     protected ElementScanner6(){
-        DEFAULT_VALUE = null;
+        super();
     }
 
     /**
      * Constructor for concrete subclasses; uses the argument for the
      * default value.
      */
     protected ElementScanner6(R defaultValue){
-        DEFAULT_VALUE = defaultValue;
-    }
-
-    /**
-     * Iterates over the given elements and calls {@link
-     * #scan(Element, Object) scan(Element, P)} on each one.  Returns
-     * the result of the last call to {@code scan} or {@code
-     * DEFAULT_VALUE} for an empty iterable.
-     *
-     * @param iterable the elements to scan
-     * @param  p additional parameter
-     * @return the scan of the last element or {@code DEFAULT_VALUE} if no elements
-     */
-    public final R scan(Iterable<? extends Element> iterable, P p) {
-        R result = DEFAULT_VALUE;
-        for(Element e : iterable)
-            result = scan(e, p);
-        return result;
-    }
-
-    /**
-     * Processes an element by calling {@code e.accept(this, p)};
-     * this method may be overridden by subclasses.
-     * @return the result of visiting {@code e}.
-     */
-    public R scan(Element e, P p) {
-        return e.accept(this, p);
-    }
-
-    /**
-     * Convenience method equivalent to {@code v.scan(e, null)}.
-     * @return the result of scanning {@code e}.
-     */
-    public final R scan(Element e) {
-        return scan(e, null);
-    }
-
-    /**
-     * {@inheritDoc} This implementation scans the enclosed elements.
-     *
-     * @param e  the element to visit
-     * @param p  a visitor-specified parameter
-     * @return the result of scanning
-     */
-    public R visitPackage(PackageElement e, P p) {
-        return scan(e.getEnclosedElements(), p);
-    }
-
-    /**
-     * {@inheritDoc} This implementation scans the enclosed elements.
-     *
-     * @param e  the element to visit
-     * @param p  a visitor-specified parameter
-     * @return the result of scanning
-     */
-    public R visitType(TypeElement e, P p) {
-        return scan(e.getEnclosedElements(), p);
-    }
-
-    /**
-     * {@inheritDoc} This implementation scans the enclosed elements.
-     *
-     * @param e  the element to visit
-     * @param p  a visitor-specified parameter
-     * @return the result of scanning
-     */
-    public R visitVariable(VariableElement e, P p) {
-        return scan(e.getEnclosedElements(), p);
-    }
-
-    /**
-     * {@inheritDoc} This implementation scans the parameters.
-     *
-     * @param e  the element to visit
-     * @param p  a visitor-specified parameter
-     * @return the result of scanning
-     */
-    public R visitExecutable(ExecutableElement e, P p) {
-        return scan(e.getParameters(), p);
-    }
-
-    /**
-     * {@inheritDoc} This implementation scans the enclosed elements.
-     *
-     * @param e  the element to visit
-     * @param p  a visitor-specified parameter
-     * @return the result of scanning
-     */
-    public R visitTypeParameter(TypeParameterElement e, P p) {
-        return scan(e.getEnclosedElements(), p);
+        super(defaultValue);
     }
 }