java代码快速生成get和set方法

java 复制代码
import com.framework.emt.system.domain.exception.ExceptionCategory;

import java.lang.reflect.Method;

public class GetAllSetMethods {

    public static void main(String[] args) {
        ExceptionCategory exceptionCategory = new ExceptionCategory();
        getAllSetMethods(exceptionCategory);
    }

    public static void getAllSetMethods(Object object) {
        Class<?> clazz = object.getClass();
        Method[] methods = clazz.getMethods();

        for (Method method : methods) {
            if (isSetMethod(method)) {
                System.out.println(method.getName() + "();");
            }
        }
    }

    public static boolean isSetMethod(Method method) {
        String methodName = method.getName();
        return methodName.startsWith("set") && methodName.length() > 3;
    }

}

拿去,不用谢

相关推荐
相与还1 分钟前
IDEA实现纯java项目并打包jar(不使用Maven,Spring)
java·intellij-idea·jar
程序无bug7 分钟前
后端3行代码写出8个接口!
java·后端
摇滚侠9 分钟前
idea删除的文件怎么找回
java·ide·intellij-idea
菜鸟的迷茫9 分钟前
Spring Boot 3 + Spring Security 6 + JWT 打造企业级权限系统(拿走即用)
java
笑衬人心。37 分钟前
Spring的`@Value`注解使用详细说明
java·后端·spring
hac132241 分钟前
Spring Boot 双数据源配置
java·spring boot·后端
萧曵 丶1 小时前
Rust中Option和Result详解
开发语言·后端·rust·option·result
zhysunny1 小时前
Retrofit+RxJava:打造声明式REST客户端的艺术 —— 像点咖啡一样调用API
java·rxjava·retrofit
码不停蹄的玄黓1 小时前
深入理解MyBatis延迟加载:原理、配置与实战优化
java·mybatis·延迟加载
Lannyuu1 小时前
Java:继承和多态(必会知识点整理)
java·开发语言