An alternate implementation of Types#asElement that does not require a Types instance with the notable difference that it will throw IllegalArgumentException instead of returning null if the TypeMirror can not be converted to an Element. @throws NullPointerEx
(TypeMirror typeMirror)
| 541 | * Element} |
| 542 | */ |
| 543 | public static Element asElement(TypeMirror typeMirror) { |
| 544 | return typeMirror.accept(AsElementVisitor.INSTANCE, null); |
| 545 | } |
| 546 | |
| 547 | private static final class AsElementVisitor extends SimpleTypeVisitor8<Element, Void> { |
| 548 | private static final AsElementVisitor INSTANCE = new AsElementVisitor(); |