程序包 org.coodex.util
类 ReflectHelper
java.lang.Object
org.coodex.util.ReflectHelper
- 作者:
- Davidoff
-
嵌套类概要
嵌套类 -
字段概要
字段 -
方法概要
修饰符和类型方法说明static booleanclassExists(String className) static <S,T extends S>
SextendInterface(T o, Object... objects) static voidstatic Field[]getAllDeclaredFields(Class<?> clz) static Field[]getAllDeclaredFields(Class<?> clz, Function<Class<?>, Boolean> decision) static Class<?>[]getAllInterfaces(Class<?> clz) static <T extends Annotation>
TgetAnnotation(Class<T> annotationClass, AnnotatedElement... elements) static <T extends Annotation>
TgetAnnotation(Class<T> annotationClass, AnnotatedElement element, Set<AnnotatedElement> checked) static MethodgetLambdaMethod(Object lambda) 获取lambda表达式实例的方法签名,方法来源:https://zhuanlan.zhihu.com/p/151438084static StringgetParameterName(Object executable, int index, String prefix) static StringgetParameterName(Constructor<?> executable, int index) static StringgetParameterName(Method method, int index) static Objectstatic booleanisAssignable(Class<?> from, Class<?> to) static booleanstatic <T> TthrowExceptionObject(Class<T> interfaceClass, Function<Method, Throwable> function) static <T> TthrowExceptionObject(Class<T> interfaceClass, Supplier<Throwable> supplier) static StringtypeToCodeStr(Type type)
-
字段详细资料
-
NOT_NULL
-
ALL_OBjECT
-
ALL_OBJECT_EXCEPT_JAVA_SDK
-
-
方法详细资料
-
classExists
-
getAnnotation
public static <T extends Annotation> T getAnnotation(Class<T> annotationClass, AnnotatedElement element, Set<AnnotatedElement> checked) -
getAnnotation
public static <T extends Annotation> T getAnnotation(Class<T> annotationClass, AnnotatedElement... elements) -
getParameterName
-
getLambdaMethod
获取lambda表达式实例的方法签名,方法来源:https://zhuanlan.zhihu.com/p/151438084原理,在lambda实例的class(isSynthetic)中找到对应的方法,因为lambda表达式是单一方法的实例,所以能够找到的应该是有且仅有的一个方法
- 参数:
lambda- lambda instance- 返回:
- lambda表达式实例的方法签名
- 抛出:
ReflectiveOperationException- exception
-
getParameterName
-
getParameterName
-
getAllDeclaredFields
-
getAllDeclaredFields
-
invoke
public static Object invoke(Object obj, Method method, Object[] args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException -
foreachClass
-
throwExceptionObject
-
throwExceptionObject
-
typeToCodeStr
-
getAllInterfaces
-
isAssignable
-
isMatch
-
extendInterface
- 类型参数:
S- 必须是接口T- extends S- 参数:
o- objectobjects- 需要扩展出来的对象,只扩展接口- 返回:
- 扩展后的对象
-