From 748ee7be577efdee397dec8d479c7e8aed691496 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B6ren=20Henning?= <stu114708@informatik.uni-kiel.de>
Date: Thu, 7 Apr 2016 12:55:24 +0200
Subject: [PATCH] use Lambdas instead of Anonymous Classes

---
 .../graph/export/dot/DotFileWriterStage.java     | 16 ++++++----------
 .../graphml/GraphMLFileWriterComposite.java      | 16 ++++++----------
 2 files changed, 12 insertions(+), 20 deletions(-)

diff --git a/src/main/java/kieker/analysis/graph/export/dot/DotFileWriterStage.java b/src/main/java/kieker/analysis/graph/export/dot/DotFileWriterStage.java
index 84093915..6d0ad70a 100644
--- a/src/main/java/kieker/analysis/graph/export/dot/DotFileWriterStage.java
+++ b/src/main/java/kieker/analysis/graph/export/dot/DotFileWriterStage.java
@@ -2,7 +2,6 @@ package kieker.analysis.graph.export.dot;
 
 import java.io.FileWriter;
 import java.io.IOException;
-import java.io.Writer;
 import java.util.function.Function;
 
 import kieker.analysis.graph.Graph;
@@ -11,16 +10,13 @@ import kieker.analysis.graph.mapping.SimpleFileNameMapper;
 public class DotFileWriterStage extends DotWriterStage {
 
 	public DotFileWriterStage(final Function<Graph, String> fileNameMapper) {
-		super(new Function<Graph, Writer>() {
-			@Override
-			public Writer apply(final Graph graph) {
-				try {
-					return new FileWriter(fileNameMapper.apply(graph));
-				} catch (IOException e) {
-					throw new IllegalArgumentException(e);
-				}
+		super(fileNameMapper.andThen(fileName -> {
+			try {
+				return new FileWriter(fileName);
+			} catch (IOException e) {
+				throw new IllegalArgumentException(e);
 			}
-		});
+		}));
 	}
 
 	public DotFileWriterStage(final String outputDirectory) {
diff --git a/src/main/java/kieker/analysis/graph/export/graphml/GraphMLFileWriterComposite.java b/src/main/java/kieker/analysis/graph/export/graphml/GraphMLFileWriterComposite.java
index cc9f5223..34150188 100644
--- a/src/main/java/kieker/analysis/graph/export/graphml/GraphMLFileWriterComposite.java
+++ b/src/main/java/kieker/analysis/graph/export/graphml/GraphMLFileWriterComposite.java
@@ -2,7 +2,6 @@ package kieker.analysis.graph.export.graphml;
 
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
-import java.io.OutputStream;
 import java.util.function.Function;
 
 import kieker.analysis.graph.Graph;
@@ -11,16 +10,13 @@ import kieker.analysis.graph.mapping.SimpleFileNameMapper;
 public class GraphMLFileWriterComposite extends GraphMLWriterComposite {
 
 	public GraphMLFileWriterComposite(final Function<Graph, String> fileNameMapper) {
-		super(new Function<Graph, OutputStream>() {
-			@Override
-			public OutputStream apply(final Graph graph) {
-				try {
-					return new FileOutputStream(fileNameMapper.apply(graph));
-				} catch (FileNotFoundException e) {
-					throw new IllegalArgumentException(e);
-				}
+		super(fileNameMapper.andThen(fileName -> {
+			try {
+				return new FileOutputStream(fileName);
+			} catch (FileNotFoundException e) {
+				throw new IllegalArgumentException(e);
 			}
-		});
+		}));
 	}
 
 	public GraphMLFileWriterComposite(final String outputDirectory) {
-- 
GitLab