java.lang.Object
iu.type.TypeUtils
Miscellaneous type introspection utilities.
-
Method Summary
Modifier and TypeMethodDescription(package private) static voidcallWithContext(ClassLoader contextLoader, UnsafeRunnable runnable) Invokes anUnsafeRunnableusing a specific context class loader.(package private) static <T> TcallWithContext(ClassLoader contextLoader, UnsafeSupplier<T> supplier) Invokes anUnsafeSupplierusing a specific context class loader.(package private) static <T> TcallWithContext(AnnotatedElement element, UnsafeSupplier<T> supplier) Invokes anUnsafeSupplierusing a context appropriate for an annotated element.(package private) static ClassLoadergetContext(AnnotatedElement element) Gets the context class loader appropriate for a given annotated element.(package private) static StringPrints a generic type.(package private) static <T> IuType<?, ? super T> referTo(IuType<?, T> referrerType, Iterable<TypeFacade<?, ? super T>> hierarchy, Type referentType) Refers to a type in a hierarchy, for internal use byTypeTemplateandTypeFacade.
-
Method Details
-
getContext
Gets the context class loader appropriate for a given annotated element.- Parameters:
element- annotated element- Returns:
- class loader that loaded the element
-
callWithContext
static <T> T callWithContext(ClassLoader contextLoader, UnsafeSupplier<T> supplier) throws Throwable Invokes anUnsafeSupplierusing a specific context class loader.- Type Parameters:
T- return type- Parameters:
contextLoader-ClassLoadersupplier-UnsafeSupplier- Returns:
- result of
UnsafeSupplier.get() - Throws:
Throwable- fromUnsafeSupplier.get()
-
callWithContext
Invokes anUnsafeRunnableusing a specific context class loader.- Parameters:
contextLoader-ClassLoaderrunnable-UnsafeRunnable- Throws:
Throwable- fromUnsafeRunnable.run()
-
callWithContext
Invokes anUnsafeSupplierusing a context appropriate for an annotated element.- Type Parameters:
T- return type- Parameters:
element-AnnotatedElementsupplier-UnsafeSupplier- Returns:
- result of
UnsafeSupplier.get() - Throws:
Throwable- fromUnsafeSupplier.get()
-
printType
Prints a generic type.- Parameters:
type- generic type- Returns:
- human-readable form
-
referTo
static <T> IuType<?,? super T> referTo(IuType<?, T> referrerType, Iterable<TypeFacade<?, ? super T>> hierarchy, Type referentType) Refers to a type in a hierarchy, for internal use byTypeTemplateandTypeFacade.- Type Parameters:
T- referrer type- Parameters:
referrerType- referrer type facadehierarchy- referrer's type hierarchyreferentType- generic referent type to match- Returns:
- inherited type facade with same erasure as the
referentType
-