Class TypeLookup
java.lang.Object
io.micronaut.sourcegen.model.TypeLookup
Finds a type by its binary name while a file is written: the compiler's element where a context of the round is
given - the only thing that knows a type compiled or generated in the same round - and else the class, loaded by
reflection without being initialized.
A class that cannot be loaded is remembered per class loader, whose classpath does not change, so that the types a generated file names are not looked for again on every question asked about them. The elements a context finds are remembered for as long as the lookup is used.
- Since:
- 2.3
-
Method Summary
Modifier and TypeMethodDescription@Nullable io.micronaut.inject.ast.ClassElementclassElement(String name) The compiler's element of a type.@Nullable ClassTypeDefA type by its binary name: the compiler's element where the context knows it, else the loaded class.@Nullable Class<?> Loads the class of a type: the class of a parameterized type, and the array class of an array.@Nullable Class<?> Loads a class by its binary name, or the name of a primitive, without initializing it.static TypeLookupof(@Nullable io.micronaut.inject.visitor.VisitorContext context) static TypeLookupof(@Nullable io.micronaut.inject.visitor.VisitorContext context, ClassLoader classLoader) static TypeLookup
-
Method Details
-
reflective
- Returns:
- The lookup of classes alone, through the class loader of the generators
-
of
- Parameters:
context- The context of the round, ornull- Returns:
- The lookup of the context's elements and of classes through the class loader of the generators
-
of
public static TypeLookup of(@Nullable io.micronaut.inject.visitor.VisitorContext context, ClassLoader classLoader) - Parameters:
context- The context of the round, ornullclassLoader- The class loader classes are loaded through- Returns:
- The lookup
-
find
A type by its binary name: the compiler's element where the context knows it, else the loaded class.- Parameters:
name- The binary name- Returns:
- The type, or
nullwhere neither knows it
-
classElement
The compiler's element of a type.- Parameters:
name- The binary name- Returns:
- The element, or
nullwithout a context, or where it does not know the type
-
loadClass
-
loadClass
-