当前位置:网站首页>Parse method's parameter list (including parameter names)
Parse method's parameter list (including parameter names)
2022-08-10 23:29:00 【Technical log】
Don't say much, just go to Demo:
public class User {public static void main(String[] args) throws NoSuchMethodException {getMethodParams(User.class,"main",null);}/*** Parse method parameter list:* @param clazz: fully qualified class name* @param methodName: method name* @param agrCount: method with n parameters; if it is empty, this condition is excluded;*/public static void getMethodParams(Class clazz, String methodName, Integer agrCount) {//Get the specified method:Method method = Arrays.stream(clazz.getMethods()).filter((x) -> {return methodName.equals(x.getName()) && (Objects.isNull(agrCount) || agrCount.equals(x.getParameterCount()));}).findFirst().orElse(null);//Get parameter information:if (Objects.nonNull(method)) {for (Parameter parameter : method.getParameters()) {System.out.println("Parameter type: " + parameter.getType());System.out.println("Parameter name: " + parameter.getName());System.out.println("=================================");}}}}Test results:

边栏推荐
猜你喜欢
随机推荐
《DevOps围炉夜话》- Pilot - CNCF开源DevOps项目DevStream简介 - feat. PMC成员胡涛
HGAME 2022 复盘 writeup
Splunk中解决数据质量问题常见日期格式化
虎符CTF 2022 Quest-Crash Writeup
Btree索引和Hash索引
ACTF 2022 writeup
XSLeaks side channel attack (unfinished)
IFIT的架构与功能
Kubernetes 计算CPU 使用率
Kotlin 由浅入深,带你搞懂协程异常处理的那点事
国内vr虚拟全景技术领先的公司
北京党建展馆vr全景制作优点有哪些
浅谈jsfuck编码
自学软件测试不知道该如何学起,【软件测试技能图谱|自学测试路线图】
HGAME 2022 Week4 writeup
大厂面试热点:“热修复机制及常见的几个框架介绍”
How to bounce the shell
Android面试冲刺:2022全新面试题——剑指Offer(备战金九银十)
实例051:按位与
实例049:lambda









