From bf33eaf2cf4ae04965983bf0129e50f71b6401d2 Mon Sep 17 00:00:00 2001 From: shiyindaxiaojie <1813986321@qq.com> Date: Fri, 25 Oct 2024 23:17:33 +0800 Subject: [PATCH] update reflection utilities --- .../commons/lang/reflect/ReflectionUtils.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/eden-components/eden-commons/src/main/java/org/ylzl/eden/commons/lang/reflect/ReflectionUtils.java b/eden-components/eden-commons/src/main/java/org/ylzl/eden/commons/lang/reflect/ReflectionUtils.java index 2b2fbb53..c31d186f 100644 --- a/eden-components/eden-commons/src/main/java/org/ylzl/eden/commons/lang/reflect/ReflectionUtils.java +++ b/eden-components/eden-commons/src/main/java/org/ylzl/eden/commons/lang/reflect/ReflectionUtils.java @@ -160,6 +160,25 @@ public static List getDeclaredMethods(@NonNull Class clazz) { return methodList; } + public static String resolveMethodNameAndParams(@NonNull Method method) { + String className = method.getDeclaringClass().getName(); + String name = method.getName(); + Class[] params = method.getParameterTypes(); + + StringBuilder sb = new StringBuilder(); + sb.append(className).append(":").append(name); + sb.append("("); + int paramPos = 0; + for (Class clazz : params) { + sb.append(clazz.getCanonicalName()); + if (++paramPos < params.length) { + sb.append(","); + } + } + sb.append(")"); + return sb.toString(); + } + public static Class getSuperClassGenricType(@NonNull Class clazz, final int index) { Type genType = clazz.getGenericSuperclass(); if (!(genType instanceof ParameterizedType)) {