public final class ClassUtil extends Object
Modifier and Type | Method and Description |
---|---|
static Object |
applyMethod(Object pObject,
String pMethod,
Object... pArgs)
Apply a method to a given object with optional arguments.
|
static boolean |
checkForClass(String pClassName)
Check for the existence of a given class
|
static <T> Class<T> |
classForName(String pClassName,
boolean pInitialize,
ClassLoader... pClassLoaders)
Load a certain class.
|
static <T> Class<T> |
classForName(String pClassName,
ClassLoader... pClassLoaders)
Lookup a class.
|
static InputStream |
getResourceAsStream(String pPath)
Get the given path as an input stream or return
null if not found |
static Set<String> |
getResources(String pResource)
Get all resources from the classpath which are specified by the given path.
|
static <T> T |
newInstance(Class<T> pClass,
Object... pArguments)
Instantiate an instance of the given class with its default constructor
|
static <T> T |
newInstance(String pClassName,
Object... pArguments)
Instantiate an instance of the given class with its default constructor.
|
public static <T> Class<T> classForName(String pClassName, ClassLoader... pClassLoaders)
classForName(String, boolean,ClassLoader[])
for details. The class
gets initialized during lookup.pClassName
- name to lookup.public static <T> Class<T> classForName(String pClassName, boolean pInitialize, ClassLoader... pClassLoaders)
pClassName
- class name to loadpInitialize
- whether the class must be initializedpClassLoaders
- optional class loaders which are tried as wellpublic static InputStream getResourceAsStream(String pPath)
null
if not foundpPath
- path to lookuppublic static boolean checkForClass(String pClassName)
pClassName
- class name to checkpublic static <T> T newInstance(String pClassName, Object... pArguments)
T
- type object typepClassName
- name of class to instantiatepArguments
- optional constructor arguments. Works only for objects with the same class as declared in
the constructor types (no subclasses)IllegalArgumentException
- if the class could not be found or instantiatedpublic static <T> T newInstance(Class<T> pClass, Object... pArguments)
T
- type object typepClass
- class to instantiatepArguments
- optional constructor arguments. Works only for objects with the same class as declared in
the constructor types (no subclasses)IllegalArgumentException
- if the class could not be found or instantiatedpublic static Object applyMethod(Object pObject, String pMethod, Object... pArgs)
pObject
- object on which to apply the methodpMethod
- the method namepArgs
- optional argumentspublic static Set<String> getResources(String pResource) throws IOException
pResource
- resource specification to use for lookupIOException
Copyright © 2017. All rights reserved.