public class JavaModelUtils
extends java.lang.Object
Constructor and Description |
---|
JavaModelUtils() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
getClassArrayName(javax.lang.model.element.TypeElement typeElement)
Get the array class name for the given type element.
|
static java.lang.String |
getClassName(javax.lang.model.element.TypeElement typeElement)
Get the class name for the given type element.
|
static boolean |
isClass(javax.lang.model.element.Element element)
Whether the given element is a class.
|
static boolean |
isClassOrInterface(javax.lang.model.element.Element element)
Whether the given element is a class or interface.
|
static boolean |
isEnum(javax.lang.model.element.Element element)
Whether the given element is an enum.
|
static boolean |
isInterface(javax.lang.model.element.Element element)
Whether the given element is an interface.
|
static java.util.Optional<javax.lang.model.element.ElementKind> |
resolveKind(javax.lang.model.element.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 java.util.Optional<javax.lang.model.element.ElementKind> |
resolveKind(javax.lang.model.element.Element element,
javax.lang.model.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 java.util.Optional<javax.lang.model.element.ElementKind> resolveKind(javax.lang.model.element.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 java.util.Optional<javax.lang.model.element.ElementKind> resolveKind(javax.lang.model.element.Element element, javax.lang.model.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(javax.lang.model.element.Element element)
element
- The elementpublic static boolean isClass(javax.lang.model.element.Element element)
element
- The elementpublic static boolean isEnum(javax.lang.model.element.Element element)
element
- The elementpublic static boolean isClassOrInterface(javax.lang.model.element.Element element)
element
- The elementpublic static java.lang.String getClassName(javax.lang.model.element.TypeElement typeElement)
NestingKind
.typeElement
- The type elementpublic static java.lang.String getClassArrayName(javax.lang.model.element.TypeElement typeElement)
NestingKind
.typeElement
- The type element