public class ClassUtils
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static boolean |
extendsClass(java.lang.Class<?> childClass,
java.lang.Class<?> parentClass)
Determines if the class or interface represented by parentClass object is either the same as,
or is a superclass or superinterface of, the class or interface represented by the specified childClass parameter.
|
static boolean |
extendsClass(java.lang.Object object,
java.lang.Class<?> parentClass)
Determines if the class or interface represented by parentClass object is either the same as,
or is a superclass or superinterface of, the class of the object
|
static java.util.List<java.lang.Class<?>> |
findClasses(java.io.File directory,
java.lang.String packageName)
Recursive method used to find all classes in a given directory and subdirs.
|
static <T> java.lang.reflect.Constructor<T> |
findConstructor(java.lang.Class<T> constructorClass,
java.lang.Class<?> parameterClass)
Finds a constructor in a constructorClass that takes a parameter of parameterClass
|
static java.util.Collection<java.lang.Class<?>> |
getAllInterfaces(java.lang.Class<?> clazz) |
static java.util.List<java.lang.Class<?>> |
getClasses(java.lang.String sourceFolderPath,
java.lang.String packageName)
Scans all classes accessible from the context class loader which belong to the given package and subpackages.
|
static boolean |
implementsInterface(java.lang.Class<?> clazz,
java.lang.Class<?> interfaceClass)
Gives an information if a class implements a particular interface.
|
static boolean |
implementsInterface(java.lang.Object object,
java.lang.Class<?> interfaceClass)
Gives an information if an object implements a particular interface.
|
public static java.util.List<java.lang.Class<?>> getClasses(java.lang.String sourceFolderPath,
java.lang.String packageName)
sourceFolderPath - Path of a source folder of a root-packagepackageName - The base packagepublic static java.util.List<java.lang.Class<?>> findClasses(java.io.File directory,
java.lang.String packageName)
directory - The base directorypackageName - The package name for classes found inside the basepublic static boolean implementsInterface(java.lang.Class<?> clazz,
java.lang.Class<?> interfaceClass)
clazz - to be testedinterfaceClass - An interface classtrue, if it doesfalse, otherwisefalse, if a clazz or an interfaceClass is nullfalse, if a clazz or an interfaceClass is nullfalse, if an interfaceClass is not an interfacepublic static boolean implementsInterface(java.lang.Object object,
java.lang.Class<?> interfaceClass)
object - An objectinterfaceClass - An interface classtrue, if it doesfalse, otherwisefalse, if an object or an interface is nullfalse, if an object or an interface is nullfalse, if an interfaceClass is not an interfacepublic static boolean extendsClass(java.lang.Class<?> childClass,
java.lang.Class<?> parentClass)
childClass - A child classparentClass - A (potentially) parent classtrue, if it doesfalse, otherwisefalse, if a childClass or a parentClass is nullfalse, if a childClass or a parentClass is nullpublic static boolean extendsClass(java.lang.Object object,
java.lang.Class<?> parentClass)
object - An objectparentClass - A (potentially) parent classtrue, if it doesfalse, otherwisefalse, if an object or a (super)class is nullfalse, if an object or a (super)class is nullpublic static <T> java.lang.reflect.Constructor<T> findConstructor(java.lang.Class<T> constructorClass,
java.lang.Class<?> parameterClass)
T - A type of an object that constructor createsconstructorClass - A class-object that defines a class of a constructor that we're looking forparameterClass - A class of a constructor's parameterpublic static java.util.Collection<java.lang.Class<?>> getAllInterfaces(java.lang.Class<?> clazz)