Class ClassUtils

java.lang.Object
tech.guilhermekaua.spigotboot.core.utils.ClassUtils

public final class ClassUtils extends Object
Utility class providing helper methods for class existence checking with caching.

This class provides a safe way to check whether a class exists on a given classloader without throwing exceptions. Results are cached per classloader for performance.

  • Constructor Details

    • ClassUtils

      public ClassUtils()
  • Method Details

    • isPresent

      public static boolean isPresent(@NotNull @NotNull String className, @NotNull @NotNull ClassLoader classLoader)
      Checks whether a class with the given name is present on the specified classloader.

      This method uses ClassLoader.loadClass(String) which does NOT initialize the class, avoiding unwanted side effects from static initializers. Results are cached per classloader to avoid redundant classloader lookups.

      Parameters:
      className - the fully qualified name of the class to check, not null
      classLoader - the classloader to check for the class, not null
      Returns:
      true if the class exists on the classloader, false otherwise
      Throws:
      NullPointerException - if className or classLoader is null
    • clearCache

      public static void clearCache()