1 7 8 package javax.lang.model.util; 9 10 import javax.lang.model.element.*; 11 import static javax.lang.model.element.ElementKind.*; 12 import javax.annotation.processing.SupportedSourceVersion; 13 import static javax.lang.model.SourceVersion.*; 14 import javax.lang.model.SourceVersion; 15 16 17 64 @SupportedSourceVersion(RELEASE_6) 65 public class ElementKindVisitor6<R, P> 66 extends SimpleElementVisitor6<R, P> { 67 71 protected ElementKindVisitor6() { 72 super(null); 73 } 74 75 81 protected ElementKindVisitor6(R defaultValue) { 82 super(defaultValue); 83 } 84 85 94 @Override 95 public R visitPackage(PackageElement e, P p) { 96 assert e.getKind() == PACKAGE: "Bad kind on PackageElement"; 97 return defaultAction(e, p); 98 } 99 100 110 @Override 111 public R visitType(TypeElement e, P p) { 112 ElementKind k = e.getKind(); 113 switch(k) { 114 case ANNOTATION_TYPE: 115 return visitTypeAsAnnotationType(e, p); 116 117 case CLASS: 118 return visitTypeAsClass(e, p); 119 120 case ENUM: 121 return visitTypeAsEnum(e, p); 122 123 case INTERFACE: 124 return visitTypeAsInterface(e, p); 125 126 default: 127 throw new AssertionError ("Bad kind " + k + " for TypeElement" + e); 128 } 129 } 130 131 139 public R visitTypeAsAnnotationType(TypeElement e, P p) { 140 return defaultAction(e, p); 141 } 142 143 151 public R visitTypeAsClass(TypeElement e, P p) { 152 return defaultAction(e, p); 153 } 154 155 163 public R visitTypeAsEnum(TypeElement e, P p) { 164 return defaultAction(e, p); 165 } 166 167 175 public R visitTypeAsInterface(TypeElement e, P p) { 176 return defaultAction(e, p); 177 } 178 179 188 @Override 189 public R visitVariable(VariableElement e, P p) { 190 ElementKind k = e.getKind(); 191 switch(k) { 192 case ENUM_CONSTANT: 193 return visitVariableAsEnumConstant(e, p); 194 195 case EXCEPTION_PARAMETER: 196 return visitVariableAsExceptionParameter(e, p); 197 198 case FIELD: 199 return visitVariableAsField(e, p); 200 201 case LOCAL_VARIABLE: 202 return visitVariableAsLocalVariable(e, p); 203 204 case PARAMETER: 205 return visitVariableAsParameter(e, p); 206 207 default: 208 throw new AssertionError ("Bad kind " + k + " for VariableElement" + e); 209 } 210 211 } 212 213 221 public R visitVariableAsEnumConstant(VariableElement e, P p) { 222 return defaultAction(e, p); 223 } 224 225 233 public R visitVariableAsExceptionParameter(VariableElement e, P p) { 234 return defaultAction(e, p); 235 } 236 237 245 public R visitVariableAsField(VariableElement e, P p) { 246 return defaultAction(e, p); 247 } 248 249 257 public R visitVariableAsLocalVariable(VariableElement e, P p) { 258 return defaultAction(e, p); 259 } 260 261 269 public R visitVariableAsParameter(VariableElement e, P p) { 270 return defaultAction(e, p); 271 } 272 273 283 @Override 284 public R visitExecutable(ExecutableElement e, P p) { 285 ElementKind k = e.getKind(); 286 switch(k) { 287 case CONSTRUCTOR: 288 return visitExecutableAsConstructor(e, p); 289 290 case INSTANCE_INIT: 291 return visitExecutableAsInstanceInit(e, p); 292 293 case METHOD: 294 return visitExecutableAsMethod(e, p); 295 296 case STATIC_INIT: 297 return visitExecutableAsStaticInit(e, p); 298 299 default: 300 throw new AssertionError ("Bad kind " + k + " for ExecutableElement" + e); 301 } 302 } 303 304 312 public R visitExecutableAsConstructor(ExecutableElement e, P p) { 313 return defaultAction(e, p); 314 } 315 316 324 public R visitExecutableAsInstanceInit(ExecutableElement e, P p) { 325 return defaultAction(e, p); 326 } 327 328 336 public R visitExecutableAsMethod(ExecutableElement e, P p) { 337 return defaultAction(e, p); 338 } 339 340 348 public R visitExecutableAsStaticInit(ExecutableElement e, P p) { 349 return defaultAction(e, p); 350 } 351 352 353 362 @Override 363 public R visitTypeParameter(TypeParameterElement e, P p) { 364 assert e.getKind() == TYPE_PARAMETER: "Bad kind on TypeParameterElement"; 365 return defaultAction(e, p); 366 } 367 } 368 | Popular Tags |