Package com.helger.commons.lang
Class ClassHierarchyCache
java.lang.Object
com.helger.commons.lang.ClassHierarchyCache
A small class hierarchy cache
- Author:
- Philip Helger
-
Method Summary
Modifier and TypeMethodDescriptionstatic EChangeIt's important to clear the cache upon application shutdown, because for web applications, keeping a cache of classes may prevent the web application from unloadingstatic ICommonsSet<Class<?>> getClassHierarchy(Class<?> aClass) Get the complete super class hierarchy of the passed class including all super classes and all interfaces of the passed class and of all parent classes.static ICommonsIterable<WeakReference<Class<?>>> getClassHierarchyIterator(Class<?> aClass) Iterate the complete super class hierarchy of the passed class including all super classes and all interfaces of the passed class and of all parent classes.static ICommonsList<Class<?>> getClassHierarchyList(Class<?> aClass) Get the complete super class hierarchy of the passed class including all super classes and all interfaces of the passed class and of all parent classes.
-
Method Details
-
clearCache
It's important to clear the cache upon application shutdown, because for web applications, keeping a cache of classes may prevent the web application from unloading- Returns:
EChange
-
getClassHierarchy
@Nonnull @ReturnsMutableCopy public static ICommonsSet<Class<?>> getClassHierarchy(@Nonnull Class<?> aClass) Get the complete super class hierarchy of the passed class including all super classes and all interfaces of the passed class and of all parent classes.- Parameters:
aClass- The source class to get the hierarchy from.- Returns:
- A non-
nulland non-empty Set containing the passed class and all super classes, and all super-interfaces.
-
getClassHierarchyList
@Nonnull @ReturnsMutableCopy public static ICommonsList<Class<?>> getClassHierarchyList(@Nonnull Class<?> aClass) Get the complete super class hierarchy of the passed class including all super classes and all interfaces of the passed class and of all parent classes.- Parameters:
aClass- The source class to get the hierarchy from.- Returns:
- A non-
nulland non-empty list containing the passed class and all super classes, and all super-interfaces. Duplicates were already removed.
-
getClassHierarchyIterator
@Nonnull public static ICommonsIterable<WeakReference<Class<?>>> getClassHierarchyIterator(@Nonnull Class<?> aClass) Iterate the complete super class hierarchy of the passed class including all super classes and all interfaces of the passed class and of all parent classes.- Parameters:
aClass- The source class to get the hierarchy from.- Returns:
- A non-
nulland non-empty list containing the passed class and all super classes, and all super-interfaces. Duplicates were already removed.
-