Refactor PersonBuilder

This commit is contained in:
pivovarit 2017-01-17 06:40:44 +01:00
parent ffd8963fd5
commit deb694bc88
4 changed files with 27 additions and 17 deletions

View File

@ -10,7 +10,7 @@
<packaging>war</packaging>
<properties>
<java.min.version>1.7</java.min.version>
<java.min.version>1.8</java.min.version>
<maven.min.version>3.0.0</maven.min.version>
<junit.version>4.12</junit.version>

View File

@ -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<String> emails = new ArrayList<>();
for (JsonString j : emailsJson.getValuesAs(JsonString.class)) {
emails.add(j.getString());
}
List<String> emails = emailsJson.getValuesAs(JsonString.class).stream()
.map(JsonString::getString)
.collect(Collectors.toList());
person.setEmails(emails);

View File

@ -17,6 +17,10 @@
<dep.ver.metrics>3.1.0</dep.ver.metrics>
<dep.ver.servlet>3.1.0</dep.ver.servlet>
<dep.ver.junit>4.12</dep.ver.junit>
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
@ -52,4 +56,20 @@
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>$[maven.compiler-plugin.version]</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -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());
}
}