Package io.jmix.core.common.util
Class ReflectionHelper
java.lang.Object
io.jmix.core.common.util.ReflectionHelper
Utility class to simplify work with Java reflection.
- 
Method SummaryModifier and TypeMethodDescriptionstatic Fieldstatic MethodfindMethod(Class<?> c, String name, Object... params) Searches for a method by its name and arguments.static <T> Class<T>Load class by name, wrapping aClassNotFoundExceptioninto unchecked exception.static ObjectgetFieldValue(Object entity, String property) Useful to get real entity property value and avoid unfetched attribute exception.static Class<?>[]getParamTypes(Object... params) Constructs an array of argument types from an array of actual values.static <T> TinvokeMethod(Object obj, String name, Object... params) Invokes a method by reflection.static Class<?>Load class by name.static <T> TnewInstance(Class<T> cls, Object... params) Instantiates an object by appropriate constructor.
- 
Method Details- 
loadClassLoad class by name.- Parameters:
- name- class FQN or primitive type name
- Returns:
- class instance
- Throws:
- ClassNotFoundException- if not found
 
- 
getClassLoad class by name, wrapping aClassNotFoundExceptioninto unchecked exception.- Parameters:
- name- class FQN
- Returns:
- class instance
 
- 
newInstanceInstantiates an object by appropriate constructor.- Parameters:
- cls- class
- params- constructor arguments
- Returns:
- created object instance
- Throws:
- NoSuchMethodException- if the class has no constructor matching the given arguments
 
- 
findMethodSearches for a method by its name and arguments.- Parameters:
- c- class
- name- method name
- params- method arguments
- Returns:
- method reference or null if a suitable method not found
 
- 
invokeMethodpublic static <T> T invokeMethod(Object obj, String name, Object... params) throws NoSuchMethodException Invokes a method by reflection.- Parameters:
- obj- object instance
- name- method name
- params- method arguments
- Returns:
- method result
- Throws:
- NoSuchMethodException- if a suitable method not found
 
- 
getParamTypesConstructs an array of argument types from an array of actual values. Values can not contain nulls.- Parameters:
- params- arguments
- Returns:
- the array of argument types
 
- 
getFieldValueUseful to get real entity property value and avoid unfetched attribute exception.- Returns:
- field value
 
- 
findField
 
-