Package org.summerboot.jexpress.util
Class ReflectionUtil
java.lang.Object
org.summerboot.jexpress.util.ReflectionUtil
- Author:
- Changski Tie Zheng Zhang 张铁铮, 魏泽北, 杜旺财, 杜富贵
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetAllImplementationsByAnnotation(Class<? extends Annotation> annotation, String rootPackageName, boolean honorInherited) getAllImplementationsByInterface(Class<T> interfaceClass, String rootPackageName) getAllInterfaces(Class targetClass, boolean includeSuperClasses) getAllSuperClasses(Class targetClass) getDeclaredAndSuperClassesFields(Class targetClass) getDeclaredAndSuperClassesMethods(Class targetClass, boolean includOverriddenSuperMethod) static StringgetRootPackageName(Class callerClass) static voidloadField(Object instance, Field field, String value, boolean autoDecrypt, boolean isEmailRecipients) Load config settings with @Config, supported Java types:static StringloadFields(Class targetClass, Class fieldClass) static voidloadFields(Class targetClass, Class fieldClass, Map results, boolean includeClassName) static voidsetPluginClasses(Set<Class<?>> pluginClasses) static ObjecttoJavaType(Class targetClass, Type genericType, String value, boolean autoDecrypt, boolean isEmailRecipients, EnumConvert.To enumConvert) static ObjecttoStandardJavaType(String value, Class targetClass, boolean autoDecrypt, boolean isEmailRecipients, EnumConvert.To enumConvert) T: enum, String, boolean/Boolean, byte/Byte, short/Short, int/Integer, long/Long, float/Float, double/Double, BigDecimal, URI, URL, Path, File
-
Constructor Details
-
ReflectionUtil
public ReflectionUtil()
-
-
Method Details
-
setPluginClasses
-
getAllImplementationsByInterface
public static <T> Set<Class<? extends T>> getAllImplementationsByInterface(Class<T> interfaceClass, String rootPackageName) - Type Parameters:
T-- Parameters:
interfaceClass-rootPackageName-- Returns:
-
getAllImplementationsByAnnotation
public static Set<Class<?>> getAllImplementationsByAnnotation(Class<? extends Annotation> annotation, String rootPackageName, boolean honorInherited) - Parameters:
annotation-rootPackageName-honorInherited-- Returns:
-
getAllInterfaces
- Parameters:
targetClass-includeSuperClasses-- Returns:
- all interfaces of the targetClass
-
getAllSuperClasses
- Parameters:
targetClass-- Returns:
-
loadField
public static void loadField(Object instance, Field field, String value, boolean autoDecrypt, boolean isEmailRecipients) throws IllegalAccessException Load config settings with @Config, supported Java types:1. T, K: enum, String, boolean/Boolean, byte/Byte, char/short/Short, int/Integer, long/Long, float/Float, double/Double, BigDecimal, URI, URL, Path, File 2. <T>[] array 3. Immutable Set, Immutable SortedSet<T> 4. Immutable List<T> 5. Immutable Map<T, K> 6. KeyManagerFactory 7. TrustManagerFactory- Parameters:
instance-field-value-autoDecrypt-isEmailRecipients-- Throws:
IllegalAccessException
-
toJavaType
public static Object toJavaType(Class targetClass, Type genericType, String value, boolean autoDecrypt, boolean isEmailRecipients, EnumConvert.To enumConvert) throws IllegalAccessException - Throws:
IllegalAccessException
-
toStandardJavaType
public static Object toStandardJavaType(String value, Class targetClass, boolean autoDecrypt, boolean isEmailRecipients, EnumConvert.To enumConvert) T: enum, String, boolean/Boolean, byte/Byte, short/Short, int/Integer, long/Long, float/Float, double/Double, BigDecimal, URI, URL, Path, File- Parameters:
value-targetClass-autoDecrypt- auto decrypt value in ENC() format if trueenumConvert-isEmailRecipients-- Returns:
-
loadFields
public static void loadFields(Class targetClass, Class fieldClass, Map results, boolean includeClassName) throws IllegalArgumentException, IllegalAccessException -
loadFields
public static String loadFields(Class targetClass, Class fieldClass) throws IllegalArgumentException, IllegalAccessException, com.fasterxml.jackson.core.JsonProcessingException - Throws:
IllegalArgumentExceptionIllegalAccessExceptioncom.fasterxml.jackson.core.JsonProcessingException
-
getRootPackageName
-
getDeclaredAndSuperClassesFields
-
getDeclaredAndSuperClassesMethods
-