mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
extract method object: do not process inner classes return statements (IDEA-63806)
This commit is contained in:
+55
@@ -0,0 +1,55 @@
|
||||
public class Demo {
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
<selection>Pojo1 p1 = new Pojo1("p1");
|
||||
Pojo2 p2 = new Pojo2("p2"){
|
||||
@Override
|
||||
public String getContent() {
|
||||
return "------------";
|
||||
}
|
||||
};
|
||||
</selection>
|
||||
|
||||
System.out.println(p1.getContent() + p2.getContent());
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static class Pojo1 {
|
||||
private String content;
|
||||
|
||||
public Pojo1(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Pojo2 {
|
||||
private String content;
|
||||
|
||||
public Pojo2(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
public class Demo {
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
Inner inner = new Inner().invoke();
|
||||
Pojo1 p1 = inner.getP1();
|
||||
Pojo2 p2 = inner.getP2();
|
||||
|
||||
|
||||
System.out.println(p1.getContent() + p2.getContent());
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static class Pojo1 {
|
||||
private String content;
|
||||
|
||||
public Pojo1(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Pojo2 {
|
||||
private String content;
|
||||
|
||||
public Pojo2(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
}
|
||||
|
||||
private static class Inner {
|
||||
private Pojo1 p1;
|
||||
private Pojo2 p2;
|
||||
|
||||
public Pojo1 getP1() {
|
||||
return p1;
|
||||
}
|
||||
|
||||
public Pojo2 getP2() {
|
||||
return p2;
|
||||
}
|
||||
|
||||
public Inner invoke() {
|
||||
p1 = new Pojo1("p1");
|
||||
p2 = new Pojo2("p2") {
|
||||
@Override
|
||||
public String getContent() {
|
||||
return "------------";
|
||||
}
|
||||
};
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user