在IntelliJ中是否可以进行这种重构
public class Demo {
public long sum(Model model) {
int a = model.getA();
int b = model.getB();
System.out.println(model.getA());
System.out.println(model.getB());
return (long) a + b;
}
//refactor to
public long sum(int a, int b) {
System.out.println(a);
System.out.println(b);
return (long) a + b;
}
private static class Model {
private int a;
private int b;
private int c;
//getter & boilerplate
}
}
恕我直言,在某些情况下可以降低复杂性。
谷歌搜索了一段时间,并尝试了各种重构对话-找不到比“更改签名”更好的东西了。
编辑:改进示例以使每个参数具有多种用法