public class ClassUtils extends Object
Collection of utilities to ease working with reflection.
Constructor and Description |
---|
ClassUtils() |
Modifier and Type | Method and Description |
---|---|
static List<Class<?>> |
getAllClassesInPackage(String packageName) |
static Class<?> |
getClass(String className)
Get a Java class from its name.
|
static Object |
getNewInstance(Class<?> klass)
Instantiates a class and returns the instance.
|
static List<Class<?>> |
getSubClassesInPackage(String packageName,
Class<?> superClass) |
static boolean |
isPresent(String className)
Determine whether the
Class identified by the supplied name is
present and can be loaded. |
public static Class<?> getClass(String className) throws ClassNotFoundException
Get a Java class from its name.
className
- The name of the class to load.ClassNotFoundException
- if none of the ClassLoaders is able to found the class.public static Object getNewInstance(Class<?> klass) throws InstantiationException, IllegalAccessException
klass
- The class to instantiate.IllegalAccessException
InstantiationException
public static boolean isPresent(String className)
Class
identified by the supplied name is
present and can be loaded. Will return false
if either the class
or one of its dependencies is not present or cannot be loaded.className
- The fully qualified name of the class to check.public static List<Class<?>> getSubClassesInPackage(String packageName, Class<?> superClass) throws ClassNotFoundException, IOException
ClassNotFoundException
IOException
public static List<Class<?>> getAllClassesInPackage(String packageName) throws ClassNotFoundException, IOException
ClassNotFoundException
IOException
Copyright © 2013-2015 Dandelion Project. All Rights Reserved.