Package io.micronaut.inject.processing
Class JavaModelUtils
java.lang.Object
io.micronaut.inject.processing.JavaModelUtils
Utility methods for Java model handling.
- Since:
- 1.0
- Author:
- graemerocher
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetClassArrayName(TypeElement typeElement) Get the array class name for the given type element.static StringgetClassname(TypedElement type) Return the type reference for a class.static StringgetClassName(TypeElement typeElement) Get the class name for the given type element.static StringgetClassNameWithoutPackage(TypeElement typeElement) Get the class name for the given type element without the package.static StringgetPackageName(TypeElement typeElement) static org.objectweb.asm.TypegetTypeReference(TypedElement type) Return the type reference for a class.static booleanChecks if passed type is either boolean primitive or wrapper.static booleanWhether the given element is a class.static booleanisClassOrInterface(Element element) Whether the given element is a class or interface.static booleanWhether the given element is an enum.static booleanisInterface(Element element) Whether the given element is an interface.static @io.micronaut.core.annotation.NonNull booleanChecks if passed type is one of numeric primitives or numeric wrappers.static booleanisPrimitive(@NonNull org.objectweb.asm.Type type) Checks if passed type is a primitive.static booleanWhether the given element is an interface.static booleanReturn whether this is a component of a record.static booleanReturn whether this is a record or a component of a record.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 andElement.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 andElement.getKind()is called.
-
Field Details
-
NAME_TO_TYPE_MAP
-
-
Constructor Details
-
JavaModelUtils
public JavaModelUtils()
-
-
Method Details
-
isPrimitive
Checks if passed type is a primitive.- Parameters:
type- type to check- Returns:
- true if it is
-
isBoolean
Checks if passed type is either boolean primitive or wrapper.- Parameters:
type- type to check- Returns:
- true if it is
-
isNumeric
@NonNull public static @io.micronaut.core.annotation.NonNull boolean isNumeric(@NonNull @NonNull org.objectweb.asm.Type type) Checks if passed type is one of numeric primitives or numeric wrappers.- Parameters:
type- type to check- Returns:
- true if it is
-
resolveKind
The Java APT throws an internal exception {code com.sun.tools.javac.code.Symbol$CompletionFailure} if a class is missing from the classpath andElement.getKind()is called. This method handles exceptions when calling the getKind() method to avoid this scenario and should be used instead ofElement.getKind().- Parameters:
element- The element- Returns:
- The kind if it is resolvable
-
resolveKind
The Java APT throws an internal exception {code com.sun.tools.javac.code.Symbol$CompletionFailure} if a class is missing from the classpath andElement.getKind()is called. This method handles exceptions when calling the getKind() method to avoid this scenario and should be used instead ofElement.getKind().- Parameters:
element- The elementexpected- The expected kind- Returns:
- The kind if it is resolvable and matches the expected kind
-
isInterface
Whether the given element is an interface.- Parameters:
element- The element- Returns:
- True if it is
-
isRecord
Whether the given element is an interface.- Parameters:
element- The element- Returns:
- True if it is
-
isClass
Whether the given element is a class.- Parameters:
element- The element- Returns:
- True if it is
-
isEnum
Whether the given element is an enum.- Parameters:
element- The element- Returns:
- True if it is
-
isClassOrInterface
Whether the given element is a class or interface.- Parameters:
element- The element- Returns:
- True if it is
-
getClassName
Get the class name for the given type element. HandlesNestingKind.- Parameters:
typeElement- The type element- Returns:
- The class name
-
getClassNameWithoutPackage
Get the class name for the given type element without the package. HandlesNestingKind.- Parameters:
typeElement- The type element- Returns:
- The class name
-
getPackageName
-
getClassArrayName
Get the array class name for the given type element. HandlesNestingKind.- Parameters:
typeElement- The type element- Returns:
- The class name
-
isRecordOrRecordComponent
Return whether this is a record or a component of a record.- Parameters:
e- The element- Returns:
- True if it is
-
isRecordComponent
Return whether this is a component of a record.- Parameters:
e- The element- Returns:
- True if it is
-
getTypeReference
Return the type reference for a class.- Parameters:
type- The type- Returns:
- The
Type
-
getClassname
Return the type reference for a class.- Parameters:
type- The type- Returns:
- The
Type
-