| 构造器和说明 |
|---|
ClassUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static Class<?> |
forName(String className)
Get class by class name.
|
static Class<?> |
forName(@Nullable String className,
Class<?> defaultClass)
Get class by class name, if class not found, return default class.
|
static boolean |
isInstantiable(Class<?> type,
@Nullable Consumer<Throwable> fallback)
Whether the given class is instantiable.
|
static boolean |
isJdkClass(Class<?> clazz)
Whether the given class is from packages
which package name is started with "java." or "javax.".
|
static boolean |
isObjectOrVoid(Class<?> clazz)
Whether the given class is
Object or Void. |
static boolean |
isPrimitiveTypeOrWrapperType(Class<?> type)
Whether the given class is primitive type or wrapper type.
|
static <T> T |
newInstance(@NonNull Class<?> type,
Object... args)
Create new instance of given type.
|
static String |
packageToPath(String packagePath)
Convert the package path to the resource path.
|
public static boolean isPrimitiveTypeOrWrapperType(Class<?> type)
type - typepublic static boolean isObjectOrVoid(Class<?> clazz)
Object or Void.clazz - clazzpublic static boolean isJdkClass(Class<?> clazz)
Whether the given class is from packages which package name is started with "java." or "javax.".
clazz - classpublic static Class<?> forName(String className) throws Crane4jException
Get class by class name.
className - class nameCrane4jException - if class not foundpublic static Class<?> forName(@Nullable String className, Class<?> defaultClass)
Get class by class name, if class not found, return default class.
className - class name, it may be null or emptydefaultClass - default classCrane4jException - if class which specified by className not foundpublic static <T> T newInstance(@NonNull Class<?> type, Object... args)
Create new instance of given type.
T - typetype - typeCrane4jException - if create instance failedpublic static boolean isInstantiable(Class<?> type, @Nullable Consumer<Throwable> fallback)
Whether the given class is instantiable.
type - typefallback - fallback when create instance failed, usually used for loggingCopyright © 2024. All rights reserved.