From deb694bc885e970828946c21b530fd1b7e6cfa62 Mon Sep 17 00:00:00 2001 From: pivovarit Date: Tue, 17 Jan 2017 06:40:44 +0100 Subject: [PATCH] Refactor PersonBuilder --- jee7/pom.xml | 2 +- .../java/com/baeldung/json/PersonBuilder.java | 17 +++++----------- metrics/pom.xml | 20 +++++++++++++++++++ .../baeldung/springretry/SpringRetryTest.java | 5 +---- 4 files changed, 27 insertions(+), 17 deletions(-) diff --git a/jee7/pom.xml b/jee7/pom.xml index 66991d03a8..f275f56d58 100644 --- a/jee7/pom.xml +++ b/jee7/pom.xml @@ -10,7 +10,7 @@ war - 1.7 + 1.8 3.0.0 4.12 diff --git a/jee7/src/main/java/com/baeldung/json/PersonBuilder.java b/jee7/src/main/java/com/baeldung/json/PersonBuilder.java index 5d060827dc..a9ac4032ce 100644 --- a/jee7/src/main/java/com/baeldung/json/PersonBuilder.java +++ b/jee7/src/main/java/com/baeldung/json/PersonBuilder.java @@ -1,17 +1,12 @@ package com.baeldung.json; +import javax.json.*; import java.io.IOException; import java.io.StringReader; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.ArrayList; import java.util.List; - -import javax.json.Json; -import javax.json.JsonArray; -import javax.json.JsonObject; -import javax.json.JsonReader; -import javax.json.JsonString; +import java.util.stream.Collectors; public class PersonBuilder { private String jsonString; @@ -35,11 +30,9 @@ public class PersonBuilder { JsonArray emailsJson = jsonObject.getJsonArray("emails"); - List emails = new ArrayList<>(); - - for (JsonString j : emailsJson.getValuesAs(JsonString.class)) { - emails.add(j.getString()); - } + List emails = emailsJson.getValuesAs(JsonString.class).stream() + .map(JsonString::getString) + .collect(Collectors.toList()); person.setEmails(emails); diff --git a/metrics/pom.xml b/metrics/pom.xml index df22f1aca6..0829c9a116 100644 --- a/metrics/pom.xml +++ b/metrics/pom.xml @@ -17,6 +17,10 @@ 3.1.0 3.1.0 4.12 + + 3.6.0 + 1.8 + 1.8 @@ -52,4 +56,20 @@ test + + + + + + org.apache.maven.plugins + maven-compiler-plugin + $[maven.compiler-plugin.version] + + ${maven.compiler.source} + ${maven.compiler.target} + + + + + \ No newline at end of file diff --git a/spring-all/src/test/java/org/baeldung/springretry/SpringRetryTest.java b/spring-all/src/test/java/org/baeldung/springretry/SpringRetryTest.java index 2f3411957e..3027d67d9e 100644 --- a/spring-all/src/test/java/org/baeldung/springretry/SpringRetryTest.java +++ b/spring-all/src/test/java/org/baeldung/springretry/SpringRetryTest.java @@ -32,9 +32,6 @@ public class SpringRetryTest { @Test(expected = RuntimeException.class) public void givenTemplateRetryService_whenCallWithException_thenRetry() { - retryTemplate.execute(arg0 -> { - myService.templateRetryService(); - return null; - }); + retryTemplate.execute(arg0 -> myService.templateRetryService()); } }