public final class ClassUtil extends Object
| 限定符和类型 | 方法和说明 |
|---|---|
static ClassLoader |
getClassLoader()
Return the default ClassLoader to use: typically the thread context
ClassLoader, if available; the ClassLoader that loaded the ClassUtils
class will be used as fallback.
|
static ClassLoader |
getClassLoader(Class<?> clazz)
get class loader
|
static String |
nullSafeToString(Class<?>... classes)
Generate a comma-separated list of fully qualified class names for the
supplied classes.
|
static String |
nullSafeToString(Class<?> clazz)
Get the fully qualified name of the supplied class.
|
static String |
nullSafeToString(Function<? super Class<?>,? extends String> mapper,
Class<?>... classes)
Generate a comma-separated list of mapped values for the supplied classes.
|
public static String nullSafeToString(Class<?> clazz)
This is a null-safe variant of Class.getName().
clazz - the class whose name should be retrieved, potentially null"null" if the supplied
class reference is nullnullSafeToString(Class...),
StringUtils.nullSafeToString(Object)public static String nullSafeToString(Class<?>... classes)
classes - the classes whose names should be included in the generated stringnull or emptynullSafeToString(Function, Class...),
StringUtils.nullSafeToString(Object)public static String nullSafeToString(Function<? super Class<?>,? extends String> mapper, Class<?>... classes)
The values are generated by the supplied mapper
(e.g., Class::getName, Class::getSimpleName, etc.), unless
a class reference is null in which case it will be mapped to "null".
mapper - the mapper to use; never nullclasses - the classes to mapnull or emptynullSafeToString(Class...),
StringUtils.nullSafeToString(Object)public static ClassLoader getClassLoader()
Call this method if you intend to use the thread context ClassLoader in a
scenario where you absolutely need a non-null ClassLoader reference: for
example, for class path resource loading (but not necessarily for
Class.forName, which accepts a null ClassLoader
reference as well).
null)Thread.getContextClassLoader()public static ClassLoader getClassLoader(Class<?> clazz)
clazz - Copyright © 2021. All rights reserved.