Class ClassHierarchyCache


  • @ThreadSafe
    public final class ClassHierarchyCache
    extends Object
    A small class hierarchy cache
    Author:
    Philip Helger
    • Method Detail

      • clearCache

        @Nonnull
        public static EChange 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-null and 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-null and 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-null and non-empty list containing the passed class and all super classes, and all super-interfaces. Duplicates were already removed.