mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-04 17:20:55 +07:00
introduce functional: convert to lambda when applicable (IDEA-174018)
This commit is contained in:
@@ -3,12 +3,8 @@ import java.util.function.Supplier;
|
||||
class Test {
|
||||
void foo() {
|
||||
if (true) {
|
||||
Supplier<String> supplier = new Supplier<String>() {
|
||||
public String get() {
|
||||
return "Hello, world";
|
||||
}
|
||||
};
|
||||
System.out.println(supplier.get());
|
||||
Supplier<String> stringSupplier = () -> "Hello, world";
|
||||
System.out.println(stringSupplier.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,11 +2,7 @@ import java.util.function.Supplier;
|
||||
|
||||
class Test {
|
||||
void foo() {
|
||||
Supplier<String> supplier = new Supplier<String>() {
|
||||
public String get() {
|
||||
return "Hello, world";
|
||||
}
|
||||
};
|
||||
System.out.println(supplier.get());
|
||||
Supplier<String> stringSupplier = () -> "Hello, world";
|
||||
System.out.println(stringSupplier.get());
|
||||
}
|
||||
}
|
||||
@@ -4,12 +4,8 @@ class Test {
|
||||
String myName;
|
||||
void foo() {
|
||||
if (true) {
|
||||
Consumer<String> consumer = new Consumer<String>() {
|
||||
public void accept(String myName) {
|
||||
System.out.println("Hello, world " + myName);
|
||||
}
|
||||
};
|
||||
consumer.accept(myName);
|
||||
Consumer<String> stringConsumer = myName -> System.out.println("Hello, world " + myName);
|
||||
stringConsumer.accept(myName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,7 @@
|
||||
class Test {
|
||||
void foo(String name) {
|
||||
System.out.println("Hello, ");
|
||||
Runnable runnable = new Runnable() {
|
||||
public void run() {
|
||||
System.out.println(name);
|
||||
}
|
||||
};
|
||||
Runnable runnable = () -> System.out.println(name);
|
||||
runnable.run();
|
||||
}
|
||||
}
|
||||
@@ -3,12 +3,8 @@ import java.util.function.Consumer;
|
||||
class Test {
|
||||
void foo(String s) {
|
||||
if (true) {
|
||||
Consumer<String> consumer = new Consumer<String>() {
|
||||
public void accept(String s) {
|
||||
System.out.println("Hello, world " + s);
|
||||
}
|
||||
};
|
||||
consumer.accept(s);
|
||||
Consumer<String> stringConsumer = s1 -> System.out.println("Hello, world " + s1);
|
||||
stringConsumer.accept(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,13 +3,11 @@ import java.util.function.Consumer;
|
||||
class Test {
|
||||
void foo(String s) {
|
||||
if (true) {
|
||||
Consumer<String> consumer = new Consumer<String>() {
|
||||
public void accept(String s) {
|
||||
System.out.println("Hello, world " + s);
|
||||
System.out.println();
|
||||
}
|
||||
Consumer<String> stringConsumer = s1 -> {
|
||||
System.out.println("Hello, world " + s1);
|
||||
System.out.println();
|
||||
};
|
||||
consumer.accept(s);
|
||||
stringConsumer.accept(s);
|
||||
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user