java.lang.Object
iu.type.TypeUtils
Miscellaneous type introspection utilities.
-
Method Summary
Modifier and TypeMethodDescription(package private) static void
callWithContext
(ClassLoader contextLoader, UnsafeRunnable runnable) Invokes anUnsafeRunnable
using a specific context class loader.(package private) static <T> T
callWithContext
(ClassLoader contextLoader, UnsafeSupplier<T> supplier) Invokes anUnsafeSupplier
using a specific context class loader.(package private) static <T> T
callWithContext
(AnnotatedElement element, UnsafeSupplier<T> supplier) Invokes anUnsafeSupplier
using a context appropriate for an annotated element.(package private) static ClassLoader
getContext
(AnnotatedElement element) Gets the context class loader appropriate for a given annotated element.(package private) static String
Prints 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 byTypeTemplate
andTypeFacade
.
-
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 anUnsafeSupplier
using a specific context class loader.- Type Parameters:
T
- return type- Parameters:
contextLoader
-ClassLoader
supplier
-UnsafeSupplier
- Returns:
- result of
UnsafeSupplier.get()
- Throws:
Throwable
- fromUnsafeSupplier.get()
-
callWithContext
Invokes anUnsafeRunnable
using a specific context class loader.- Parameters:
contextLoader
-ClassLoader
runnable
-UnsafeRunnable
- Throws:
Throwable
- fromUnsafeRunnable.run()
-
callWithContext
Invokes anUnsafeSupplier
using a context appropriate for an annotated element.- Type Parameters:
T
- return type- Parameters:
element
-AnnotatedElement
supplier
-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 byTypeTemplate
andTypeFacade
.- 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
-