Package org.camunda.bpm.engine.impl.util
Class ReflectUtil
java.lang.Object
org.camunda.bpm.engine.impl.util.ReflectUtil
- Author:
- Tom Baeyens
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T
createInstance
(Class<? extends T> clazz) static ClassLoader
static Field
Returns the field of the given class or null if it doesnt exist.static Field
Returns the field of the given object or null if it doesnt exist.static Method
Finds a method by name and parameter types.static URL
getResource
(String name) static InputStream
getResourceAsStream
(String name) static String
getResourceUrlAsString
(String name) static Method
Returns the setter-method for the given field name or null if no setter exists.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.static <T> T
instantiate
(Class<T> type) static Object
instantiate
(String className) static Object
instantiate
(String className, Object[] args) static Object
static Class<?>
static <T> Class<? extends T>
loadClass
(String className, ClassLoader customClassloader, Class<T> clazz) static void
static URI
Converts an url to an uri.
-
Constructor Details
-
ReflectUtil
public ReflectUtil()
-
-
Method Details
-
getClassLoader
-
loadClass
-
loadClass
public static <T> Class<? extends T> loadClass(String className, ClassLoader customClassloader, Class<T> clazz) throws ClassNotFoundException, ClassCastException -
getResourceAsStream
-
getResource
-
getResourceUrlAsString
-
urlToURI
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
-
instantiate
-
createInstance
-
invoke
-
getField
Returns the field of the given object or null if it doesnt exist. -
getField
Returns the field of the given class or null if it doesnt exist. -
setField
-
getSetter
Returns the setter-method for the given field name or null if no setter exists. -
getSingleSetter
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. -
instantiate
-
getMethod
public static Method getMethod(Class<?> declaringType, String methodName, Class<?>... parameterTypes) Finds a method by name and parameter types.- Parameters:
declaringType
- the name of the classmethodName
- the name of the method to look forparameterTypes
- the types of the parameters
-