public class ClassUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static Class<?> |
forName(String classname) |
static Class<?> |
forName(String classname,
boolean init) |
static Class<?> |
forName(String classname,
boolean init,
Class<?> fallback) |
static Class<?> |
forName(String classname,
boolean init,
Thread thread) |
static Class<?> |
forName(String classname,
boolean init,
Thread thread,
Class<?> fallback) |
static ClassLoader |
getClassLoader() |
static ClassLoader |
getClassLoader(Class<?> fallback) |
static ClassLoader |
getClassLoader(Thread thread) |
static ClassLoader |
getClassLoader(Thread thread,
Class<?> fallback) |
static URL |
getClasspathResource(Class<?> scope,
String resource) |
static InputStream |
getClasspathResourceAsStream(Class<?> scope,
String resource) |
static Enumeration<URL> |
getClasspathResources(Class<?> scope,
String resource) |
static String |
getPackageResourcePath(Class<?> scope,
String resource) |
static Class<?> |
getTypeArgument(Class<?> cls,
Class<?> genericCls) |
static Class<?>[] |
getTypeArguments(Class<?> cls,
Class<?> genericCls) |
static boolean |
isAssignable(Class<?> cls,
Set<Class<?>> classes) |
static boolean |
isAssignableToAll(Class<?> cls,
Set<Class<?>> classes) |
static Class<?> |
toClass(Class<?> declaringCls,
Type type) |
public static Class<?> getTypeArgument(Class<?> cls, Class<?> genericCls)
type - genericCls - public static Class<?>[] getTypeArguments(Class<?> cls, Class<?> genericCls)
type - genericCls - public static boolean isAssignable(Class<?> cls, Set<Class<?>> classes)
true if cls is assignable to at least
one class in classespublic static boolean isAssignableToAll(Class<?> cls, Set<Class<?>> classes)
true if cls is assignable to all
classespublic static Class<?> forName(String classname) throws ClassNotFoundException
ClassNotFoundExceptionpublic static Class<?> forName(String classname, boolean init) throws ClassNotFoundException
ClassNotFoundExceptionpublic static Class<?> forName(String classname, boolean init, Thread thread) throws ClassNotFoundException
ClassNotFoundExceptionpublic static Class<?> forName(String classname, boolean init, Class<?> fallback) throws ClassNotFoundException
ClassNotFoundExceptionpublic static Class<?> forName(String classname, boolean init, Thread thread, Class<?> fallback) throws ClassNotFoundException
- classname - fully qualified name of the desired classinit - whether the class must be initializedthread - thread to use for context classloader or null for
current threadfallback - ClassLoader providing class if no context classloader
or null for this classClassNotFoundException - if the class cannot be located by the specified class loaderThread.currentThread(),
Thread.getContextClassLoader(),
Class.getClassLoader(),
Class.forName(String, boolean, ClassLoader)public static ClassLoader getClassLoader()
public static ClassLoader getClassLoader(Class<?> fallback)
public static ClassLoader getClassLoader(Thread thread)
public static ClassLoader getClassLoader(Thread thread, Class<?> fallback)
thread - Thread to use for
context ClassLoader or
null for current
threadfallback - ClassLoader providing class if no context classloader
or null for this classnullpublic static InputStream getClasspathResourceAsStream(Class<?> scope, String resource)
public static Enumeration<URL> getClasspathResources(Class<?> scope, String resource) throws IOException
Copyright © 2014 Molindo GmbH. All Rights Reserved.