public class Reflections extends Object
| Constructor and Description |
|---|
Reflections() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
classExists(String fqcn)
Check if class exists.
|
static boolean |
classExistsInJar(File jar,
String fqcn)
Check if a class is in a jar.
|
static boolean |
classImplementsIface(String fqcn,
Class xface)
check if class implements interface.
|
static boolean |
classInJarImplementsIface(File jar,
String fqcn,
Class xface)
check if a class implements an interface.
|
static <T> T |
createInstance(String userClassName,
Class<T> xface,
ClassLoader classLoader)
Create an instance of
userClassName using provided classLoader. |
static Object |
createInstance(String userClassName,
ClassLoader classLoader)
Create an instance of
userClassName using provided classLoader. |
static Object |
createInstance(String userClassName,
ClassLoader classLoader,
Object[] params,
Class[] paramTypes) |
static Object |
createInstance(String userClassName,
File jar) |
static List<Field> |
getAllFields(Class<?> type) |
static Class |
loadClass(String className,
ClassLoader classLoader)
Load class to resolve array types.
|
public static <T> T createInstance(String userClassName, Class<T> xface, ClassLoader classLoader)
userClassName using provided classLoader.
This instance should implement the provided interface xface.userClassName - user class namexface - the interface that the reflected instance should implementclassLoader - class loader to load the class.public static Object createInstance(String userClassName, ClassLoader classLoader)
userClassName using provided classLoader.userClassName - user class nameclassLoader - class loader to load the class.public static Object createInstance(String userClassName, ClassLoader classLoader, Object[] params, Class[] paramTypes)
public static boolean classExistsInJar(File jar, String fqcn)
jar - location of the jarfqcn - fully qualified class name to search for in jarpublic static boolean classExists(String fqcn)
fqcn - fully qualified class name to search forpublic static boolean classInJarImplementsIface(File jar, String fqcn, Class xface)
fqcn - fully qualified class name to search for in jarxface - interface to check if implementpublic static boolean classImplementsIface(String fqcn, Class xface)
fqcn - fully qualified class namexface - the interface the fqcn should implementpublic static Class loadClass(String className, ClassLoader classLoader) throws ClassNotFoundException
className - class nameclassLoader - class loaderClassNotFoundExceptionCopyright © 2017–2022 Apache Software Foundation. All rights reserved.