1 7 8 package javax.lang.model.util; 9 10 import javax.lang.model.element.*; 11 import javax.annotation.processing.SupportedSourceVersion; 12 import static javax.lang.model.element.ElementKind.*; 13 import javax.lang.model.SourceVersion; 14 import static javax.lang.model.SourceVersion.*; 15 16 17 76 @SupportedSourceVersion(RELEASE_6) 77 public class ElementScanner6<R, P> extends AbstractElementVisitor6<R, P> { 78 81 protected final R DEFAULT_VALUE; 82 83 87 protected ElementScanner6(){ 88 DEFAULT_VALUE = null; 89 } 90 91 95 protected ElementScanner6(R defaultValue){ 96 DEFAULT_VALUE = defaultValue; 97 } 98 99 109 public final R scan(Iterable <? extends Element> iterable, P p) { 110 R result = DEFAULT_VALUE; 111 for(Element e : iterable) 112 result = scan(e, p); 113 return result; 114 } 115 116 121 public R scan(Element e, P p) { 122 return e.accept(this, p); 123 } 124 125 129 public final R scan(Element e) { 130 return scan(e, null); 131 } 132 133 140 public R visitPackage(PackageElement e, P p) { 141 return scan(e.getEnclosedElements(), p); 142 } 143 144 151 public R visitType(TypeElement e, P p) { 152 return scan(e.getEnclosedElements(), p); 153 } 154 155 162 public R visitVariable(VariableElement e, P p) { 163 return scan(e.getEnclosedElements(), p); 164 } 165 166 173 public R visitExecutable(ExecutableElement e, P p) { 174 return scan(e.getParameters(), p); 175 } 176 177 184 public R visitTypeParameter(TypeParameterElement e, P p) { 185 return scan(e.getEnclosedElements(), p); 186 } 187 } 188 | Popular Tags |