Skip to content

Commit 9e56e5c

Browse files
authored
Merge pull request iluwatar#791 from er2/executeAroundLambda
Execute Around - use lambda
2 parents 1698b06 + ec6d2a8 commit 9e56e5c

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

execute-around/src/main/java/com/iluwatar/execute/around/App.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
*/
2323
package com.iluwatar.execute.around;
2424

25-
import java.io.FileWriter;
2625
import java.io.IOException;
2726

2827
/**
@@ -42,14 +41,11 @@ public class App {
4241
*/
4342
public static void main(String[] args) throws IOException {
4443

45-
new SimpleFileWriter("testfile.txt", new FileWriterAction() {
46-
47-
@Override
48-
public void writeFile(FileWriter writer) throws IOException {
49-
writer.write("Hello");
50-
writer.append(" ");
51-
writer.append("there!");
52-
}
53-
});
44+
FileWriterAction writeHello = writer -> {
45+
writer.write("Hello");
46+
writer.append(" ");
47+
writer.append("there!");
48+
};
49+
new SimpleFileWriter("testfile.txt", writeHello);
5450
}
5551
}

execute-around/src/main/java/com/iluwatar/execute/around/FileWriterAction.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
* Interface for specifying what to do with the file resource.
3131
*
3232
*/
33+
@FunctionalInterface
3334
public interface FileWriterAction {
3435

3536
void writeFile(FileWriter writer) throws IOException;

0 commit comments

Comments
 (0)