public static DeclaredType asDeclared(TypeMirror maybeDeclaredType) {
    return maybeDeclaredType.accept(DeclaredTypeVisitor.INSTANCE, null);
  }
Returns a {@link DeclaredType} if the {@link TypeMirror} represents a declared type such as a
class, interface, union/compound, or enum or throws an {@link IllegalArgumentException}.
common/src/main/java/com/google/auto/common/MoreTypes.java