public static TypeElement asType(Element element) {
    return element.accept(TypeElementVisitor.INSTANCE, null);
  }
Returns the given {@link Element} instance as {@link TypeElement}.

<p>This method is functionally equivalent to an {@code instanceof} check and a cast, but should
always be used over that idiom as instructed in the documentation for {@link Element}.

@throws NullPointerException if {@code element} is {@code null}
@throws IllegalArgumentException if {@code element} isn't a {@link TypeElement}.
common/src/main/java/com/google/auto/common/MoreElements.java