public class JavaModelUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.util.Map<java.lang.String,java.lang.String> |
NAME_TO_TYPE_MAP |
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(TypedElement type)
Return the type reference for a class.
|
static java.lang.String |
getClassName(javax.lang.model.element.TypeElement typeElement)
Get the class name for the given type element.
|
static java.lang.String |
getClassNameWithoutPackage(javax.lang.model.element.TypeElement typeElement)
Get the class name for the given type element without the package.
|
static java.lang.String |
getPackageName(javax.lang.model.element.TypeElement typeElement) |
static org.objectweb.asm.Type |
getTypeReference(TypedElement type)
Return the type reference for a class.
|
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 boolean |
isRecord(javax.lang.model.element.Element element)
Whether the given element is an interface.
|
static boolean |
isRecordComponent(javax.lang.model.element.Element e)
Return whether this is a component of a record.
|
static boolean |
isRecordOrRecordComponent(javax.lang.model.element.Element e)
Return whether this is a record or a component of a record.
|
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 final java.util.Map<java.lang.String,java.lang.String> NAME_TO_TYPE_MAP
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 isRecord(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 getClassNameWithoutPackage(javax.lang.model.element.TypeElement typeElement)
NestingKind
.typeElement
- The type elementpublic static java.lang.String getPackageName(javax.lang.model.element.TypeElement typeElement)
public static java.lang.String getClassArrayName(javax.lang.model.element.TypeElement typeElement)
NestingKind
.typeElement
- The type elementpublic static boolean isRecordOrRecordComponent(javax.lang.model.element.Element e)
e
- The elementpublic static boolean isRecordComponent(javax.lang.model.element.Element e)
e
- The elementpublic static org.objectweb.asm.Type getTypeReference(TypedElement type)
type
- The typeType
public static java.lang.String getClassname(TypedElement type)
type
- The typeType