mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
replace constructor with builder: do not suggest to default chain constructor params
This commit is contained in:
+18
@@ -0,0 +1,18 @@
|
||||
public class Builder {
|
||||
private int i = 2;
|
||||
private int j;
|
||||
|
||||
public Builder setI(int i) {
|
||||
this.i = i;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setJ(int j) {
|
||||
this.j = j;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Test createTest() {
|
||||
return new Test(i, j);
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
public class Test {
|
||||
public Test(int i, int j){}
|
||||
public Test(int j){
|
||||
this(2, j);
|
||||
}
|
||||
void foo(){}
|
||||
public static void main(String[] args){
|
||||
new Builder().setJ(1).createTest().foo();
|
||||
new Builder().setI(2).setJ(3).createTest().foo();
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
public class Test {
|
||||
public Test(int i, int j){}
|
||||
public Test(int j){
|
||||
this(2, j);
|
||||
}
|
||||
void foo(){}
|
||||
public static void main(String[] args){
|
||||
new Test(1).foo();
|
||||
new Test(2, 3).foo();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user