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;
}
}
拿去,不用谢