public class JavaModelUtils extends Object
Constructor and Description |
---|
JavaModelUtils() |
Modifier and Type | Method and Description |
---|---|
static String |
getClassName(TypeElement typeElement)
Get the class name for the given type element.
|
static boolean |
isClass(Element element)
Whether the given element is a class.
|
static boolean |
isClassOrInterface(Element element)
Whether the given element is a class or interface.
|
static boolean |
isEnum(Element element)
Whether the given element is an enum.
|
static boolean |
isInterface(Element element)
Whether the given element is an interface.
|
static Optional<ElementKind> |
resolveKind(Element element)
The Java APT throws an internal exception {code com.sun.tools.javac.code.Symbol$CompletionFailure} if a class is missing from the classpath and
Element.getKind() is called. |
static Optional<ElementKind> |
resolveKind(Element element,
ElementKind expected)
The Java APT throws an internal exception {code com.sun.tools.javac.code.Symbol$CompletionFailure} if a class is missing from the classpath and
Element.getKind() is called. |
public static Optional<ElementKind> resolveKind(Element element)
Element.getKind()
is called. This method
handles exceptions when calling the getKind() method to avoid this scenario and should be used instead of Element.getKind()
.element
- The elementpublic static Optional<ElementKind> resolveKind(Element element, ElementKind expected)
Element.getKind()
is called. This method
handles exceptions when calling the getKind() method to avoid this scenario and should be used instead of Element.getKind()
.element
- The elementexpected
- The expected kindpublic static boolean isInterface(Element element)
element
- The elementpublic static boolean isClass(Element element)
element
- The elementpublic static boolean isEnum(Element element)
element
- The elementpublic static boolean isClassOrInterface(Element element)
element
- The elementpublic static String getClassName(TypeElement typeElement)
NestingKind
.typeElement
- The type element