Package io.ultreia.java4all.config
Class ApplicationConfigReflectionHelper
- java.lang.Object
-
- io.ultreia.java4all.config.ApplicationConfigReflectionHelper
-
public class ApplicationConfigReflectionHelper extends Object
Created on 19/12/2021.- Since:
- 1.0.21
- Author:
- Tony Chemit - dev@tchemit.fr
-
-
Constructor Summary
Constructors Constructor Description ApplicationConfigReflectionHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Objectcall(Object o, Method m, String... params)Call method m with params as String.static ObjectchoiceArgument(Class<?> clazz, List args, boolean nullIfMissing)Permet de matcher un type d'argument attendu clazz parmi un ensemble possible de candidat.static Objectconvert(String v, Class<?> clazz)static List<Method>getMethod(Class<?> clazz, String methodName, boolean ignoreCase)Get all methods with name given in argument without check parameters.static List<Method>getMethod(String name, boolean ignoreCase)List method that match name, name must be [package.]static <E> EnewInstance(Class<E> clazz, Collection<?> args, boolean nullIfMissing)Invoke constructor on clazz to create new instance.
-
-
-
Method Detail
-
newInstance
public static <E> E newInstance(Class<E> clazz, Collection<?> args, boolean nullIfMissing)
Invoke constructor on clazz to create new instance. Try to find argument for constructor in args parameter.- Type Parameters:
E- FIXME- Parameters:
clazz- class of object to instantiateargs- all possible parameter that constructor can usednullIfMissing- if no suitable class or object found in args, use null value (no exception)- Returns:
- new instance
- Throws:
IllegalArgumentException- if something is wrong during instantiation
-
choiceArgument
public static Object choiceArgument(Class<?> clazz, List args, boolean nullIfMissing)
Permet de matcher un type d'argument attendu clazz parmi un ensemble possible de candidat. Les candidats peuvent etre des classes qu'il faudra instancier pour satisfaire le type demande.- Parameters:
clazz- le type recherchéargs- la liste des arguments ou des typesnullIfMissing- pour retourner nulle si l'argument n'est pas trouvé- Returns:
- le type d'argument trouvé
-
getMethod
public static List<Method> getMethod(Class<?> clazz, String methodName, boolean ignoreCase)
Get all methods with name given in argument without check parameters.- Parameters:
clazz- where to search methodmethodName- method name to searchignoreCase- if true, ignore difference in method name case- Returns:
- list of detected methods
-
getMethod
public static List<Method> getMethod(String name, boolean ignoreCase)
List method that match name, name must be [package.][class][#][method] if package, class or method missing, exception throw- Parameters:
name- name of the methodignoreCase- check exact method name if false- Returns:
- list of method that match name
- Since:
- 2.6.9
-
call
public static Object call(Object o, Method m, String... params) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, InstantiationException
Call method m with params as String. Each param is converted to required type for method with beanutils converter- Parameters:
o- object where method must be callm- method to callparams- parameters for method call- Returns:
- returned method's value
- Throws:
IllegalAccessException- FIXMEIllegalArgumentException- FIXMEInvocationTargetException- FIXMEInstantiationException- FIXME
-
-