Package org.summerboot.jexpress.util
Class ReflectionUtil
java.lang.Object
org.summerboot.jexpress.util.ReflectionUtil
- Author:
- Changski Tie Zheng Zhang 张铁铮, 魏泽北, 杜旺财, 杜富贵
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetAllImplementationsByAnnotation(Class<? extends Annotation> annotation, boolean honorInherited, String... rootPackageNames) getAllImplementationsByAnnotation(Class<? extends Annotation> annotation, boolean honorInherited, Collection<String> rootPackageNames) getAllImplementationsByInterface(Class<T> interfaceClass, String... rootPackageNames) getAllImplementationsByInterface(Class<T> interfaceClass, Collection<String> rootPackageNames) getAllInterfaces(Class targetClass, boolean includeSuperClasses) getAllSuperClasses(Class targetClass) getDeclaredAndSuperClassesFields(Class targetClass) getDeclaredAndSuperClassesFields(Class targetClass, boolean isParentFirst) getDeclaredAndSuperClassesMethods(Class targetClass, boolean includOverriddenSuperMethod) static Methodstatic StringgetRootPackageName(Class callerClass, int level) static voidloadField(Object instance, Field field, String value, boolean autoDecrypt, boolean isEmailRecipients, String collectionDelimiter) 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, String collectionDelimiter) 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
-
Field Details
-
PluginClasses
-
DEFAULT_ARG_TYPES
-
-
Constructor Details
-
ReflectionUtil
public ReflectionUtil()
-
-
Method Details
-
setPluginClasses
-
getAllImplementationsByInterface
public static <T> Set<Class<? extends T>> getAllImplementationsByInterface(Class<T> interfaceClass, String... rootPackageNames) - Type Parameters:
T-- Parameters:
interfaceClass-rootPackageNames-- Returns:
-
getAllImplementationsByInterface
public static <T> Set<Class<? extends T>> getAllImplementationsByInterface(Class<T> interfaceClass, Collection<String> rootPackageNames) -
getAllImplementationsByAnnotation
public static Set<Class<?>> getAllImplementationsByAnnotation(Class<? extends Annotation> annotation, boolean honorInherited, String... rootPackageNames) - Parameters:
annotation-rootPackageNames-honorInherited-- Returns:
-
getAllImplementationsByAnnotation
public static Set<Class<?>> getAllImplementationsByAnnotation(Class<? extends Annotation> annotation, boolean honorInherited, Collection<String> rootPackageNames) -
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, String collectionDelimiter) 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-collectionDelimiter-- Throws:
IllegalAccessException
-
toJavaType
public static Object toJavaType(Class targetClass, Type genericType, String value, boolean autoDecrypt, boolean isEmailRecipients, EnumConvert.To enumConvert, String collectionDelimiter) 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
-
getDeclaredAndSuperClassesFields
-
getDeclaredAndSuperClassesMethods
-
getMethod
-