introduce functional: combine extract method & introduce

IDEA-174011; IDEA-174021
This commit is contained in:
Anna Kozlova
2017-06-07 16:57:32 +03:00
parent cb1e34fe92
commit d65ff6ad81
8 changed files with 77 additions and 111 deletions

View File

@@ -1,14 +1,14 @@
import java.util.function.Supplier;
class Test {
void foo() {
void foo() {
if (true) {
Supplier<String> stringSupplier = new Supplier<String>() {
Supplier<String> supplier = new Supplier<String>() {
public String get() {
return "Hello, world";
}
};
System.out.println(stringSupplier.get());
System.out.println(supplier.get());
}
}
}

View File

@@ -1,12 +1,12 @@
import java.util.function.Supplier;
class Test {
void foo() {
Supplier<String> stringSupplier = new Supplier<String>() {
public String get() {
return "Hello, world";
}
};
System.out.println(stringSupplier.get());
void foo() {
Supplier<String> supplier = new Supplier<String>() {
public String get() {
return "Hello, world";
}
};
System.out.println(supplier.get());
}
}

View File

@@ -1,15 +1,15 @@
import java.util.function.Consumer;
class Test {
String myName;
String myName;
void foo() {
if (true) {
Consumer<String> stringConsumer = new Consumer<String>() {
Consumer<String> consumer = new Consumer<String>() {
public void accept(String myName) {
System.out.println("Hello, world " + myName);
}
};
stringConsumer.accept(myName);
consumer.accept(myName);
}
}
}

View File

@@ -1,14 +1,14 @@
import java.util.function.Consumer;
class Test {
void foo(String s) {
void foo(String s) {
if (true) {
Consumer<String> stringConsumer = new Consumer<String>() {
Consumer<String> consumer = new Consumer<String>() {
public void accept(String s) {
System.out.println("Hello, world " + s);
}
};
stringConsumer.accept(s);
consumer.accept(s);
}
}
}
}

View File

@@ -1,16 +1,16 @@
import java.util.function.Consumer;
class Test {
void foo(String s) {
void foo(String s) {
if (true) {
Consumer<String> stringConsumer = new Consumer<String>() {
Consumer<String> consumer = new Consumer<String>() {
public void accept(String s) {
System.out.println("Hello, world " + s);
System.out.println();
}
};
stringConsumer.accept(s);
consumer.accept(s);
System.out.println();
}
}