Package org.camunda.bpm.engine.impl.util
Class ReflectUtil
- java.lang.Object
-
- org.camunda.bpm.engine.impl.util.ReflectUtil
-
public abstract class ReflectUtil extends Object
- Author:
- Tom Baeyens
-
-
Constructor Summary
Constructors Constructor Description ReflectUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> TcreateInstance(Class<? extends T> clazz)static ClassLoadergetClassLoader()static FieldgetField(String fieldName, Class<?> clazz)Returns the field of the given class or null if it doesnt exist.static FieldgetField(String fieldName, Object object)Returns the field of the given object or null if it doesnt exist.static MethodgetMethod(Class<?> declaringType, String methodName, Class<?>... parameterTypes)Finds a method by name and parameter types.static URLgetResource(String name)static InputStreamgetResourceAsStream(String name)static StringgetResourceUrlAsString(String name)static MethodgetSetter(String fieldName, Class<?> clazz, Class<?> fieldType)Returns the setter-method for the given field name or null if no setter exists.static MethodgetSingleSetter(String fieldName, Class<?> clazz)Returns a setter method based on the fieldName and the java beans setter naming convention or null if none exists.static <T> Tinstantiate(Class<T> type)static Objectinstantiate(String className)static Objectinstantiate(String className, Object[] args)static Objectinvoke(Object target, String methodName, Object[] args)static Class<?>loadClass(String className)static <T> Class<? extends T>loadClass(String className, ClassLoader customClassloader, Class<T> clazz)static voidsetField(Field field, Object object, Object value)static URIurlToURI(URL url)Converts an url to an uri.
-
-
-
Method Detail
-
getClassLoader
public static ClassLoader getClassLoader()
-
loadClass
public static <T> Class<? extends T> loadClass(String className, ClassLoader customClassloader, Class<T> clazz) throws ClassNotFoundException, ClassCastException
-
getResourceAsStream
public static InputStream getResourceAsStream(String name)
-
urlToURI
public static URI urlToURI(URL url)
Converts an url to an uri. Escapes whitespaces if needed.- Parameters:
url- the url to convert- Returns:
- the resulting uri
- Throws:
ProcessEngineException- if the url has invalid syntax
-
instantiate
public static <T> T instantiate(Class<T> type)
-
createInstance
public static <T> T createInstance(Class<? extends T> clazz)
-
getField
public static Field getField(String fieldName, Object object)
Returns the field of the given object or null if it doesnt exist.
-
getField
public static Field getField(String fieldName, Class<?> clazz)
Returns the field of the given class or null if it doesnt exist.
-
getSetter
public static Method getSetter(String fieldName, Class<?> clazz, Class<?> fieldType)
Returns the setter-method for the given field name or null if no setter exists.
-
getSingleSetter
public static Method getSingleSetter(String fieldName, Class<?> clazz)
Returns a setter method based on the fieldName and the java beans setter naming convention or null if none exists. If multiple setters with different parameter types are present, an exception is thrown. If they have the same parameter type, one of those methods is returned.
-
-