code: public static Optional<ElementKind> resolveKind(Element element, ElementKind expected) {
          final Optional<ElementKind> elementKind = resolveKind(element);
          if (elementKind.isPresent() && elementKind.get() == expected) {
              return elementKind;
          }
          return Optional.empty();
      }
docs: The Java APT throws an internal exception {code com.sun.tools.javac.code.Symbol$CompletionFailure} if a class is missing from the classpath and {@link Element#getKind()} is called. This method
  handles exceptions when calling the getKind() method to avoid this scenario and should be used instead of {@link Element#getKind()}.
  
  @param element The element
  @param expected The expected kind
  @return The kind if it is resolvable and matches the expected kind