Class ClassUtils
java.lang.Object
tech.guilhermekaua.spigotboot.core.utils.ClassUtils
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidstatic booleanisPresent(@NotNull String className, @NotNull ClassLoader classLoader) Checks whether a class with the given name is present on the specified classloader.
-
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 nullclassLoader- the classloader to check for the class, not null- Returns:
trueif the class exists on the classloader,falseotherwise- Throws:
NullPointerException- if className or classLoader is null
-
clearCache
public static void clearCache()
-