public interface ReflectionUtils
| Modifier and Type | Interface and Description |
|---|---|
static class |
ReflectionUtils.Classes |
static class |
ReflectionUtils.Constructors |
| Modifier and Type | Method and Description |
|---|---|
static <BASE> Class<? extends BASE> |
getClass(String subClassName,
Class<BASE> base) |
static Class<?> |
getClassByName(String name)
Load a class by name.
|
static Class<?> |
getClassByName(String name,
ClassLoader classLoader)
Load a class by name through a specific classloader.
|
static Class<?> |
getClassByNameOrNull(String name)
Load a class by name, returning null rather than throwing an exception
if it couldn't be loaded.
|
static Class<?> |
getClassByNameOrNull(String name,
ClassLoader classLoader)
Load a class by name through a specific classloader, returning null rather
than throwing an exception if it couldn't be loaded.
|
static ClassLoader |
getClassLoader() |
static <BASE> Class<? extends BASE> |
getImplClass(Class<BASE> base) |
static String |
getImplClassName(Class<?> clazz) |
static <T> T |
instantiate(String className,
Constructor<T> ctor,
Object[] ctorArgs) |
static <T extends Throwable> |
instantiateException(Class<T> clazz) |
static <T extends Throwable> |
instantiateException(Class<T> clazz,
String message) |
static boolean |
isInstance(Object obj,
Class<?>... classes)
Is the given object an instance of one of the given classes?
|
static <T> T |
newInstance(Class<T> clazz)
Create an object for the given class using its default constructor.
|
static <T> T |
newInstance(Class<T> clazz,
Class<?>[] argClasses,
Object... args)
Create an object for the given class using the specified constructor.
|
static ClassLoader getClassLoader()
static Class<?> getClassByNameOrNull(String name)
name - the class namestatic Class<?> getClassByNameOrNull(String name, ClassLoader classLoader)
name - the class nameclassLoader - the classloaderstatic Class<?> getClassByName(String name) throws ClassNotFoundException
name - the class name.ClassNotFoundException - if the class is not found.static Class<?> getClassByName(String name, ClassLoader classLoader) throws ClassNotFoundException
name - the class name.classLoader - the classloader.ClassNotFoundException - if the class is not found.static <T> T newInstance(Class<T> clazz)
static <T> T newInstance(Class<T> clazz, Class<?>[] argClasses, Object... args)
T - class type of clazzclazz - class of which an object is createdargClasses - argument classes of the constructorargs - actual arguments to be passed to the constructorstatic <T> T instantiate(String className, Constructor<T> ctor, Object[] ctorArgs)
static boolean isInstance(Object obj, Class<?>... classes)
static <T extends Throwable> T instantiateException(Class<T> clazz) throws Exception
ExceptionCopyright © 2017–2022 The Apache Software Foundation. All rights reserved.