Vavr refactor 02 07 (#2193)

* Vavr refactor

* Refactor
This commit is contained in:
Grzegorz Piwowarek
2017-07-02 08:07:32 +02:00
committed by GitHub
parent 6e994240f7
commit ef34fc6576
36 changed files with 356 additions and 377 deletions
@@ -4,7 +4,7 @@ public class Person {
private String name;
private int age;
public Person(String name, int age) {
Person(String name, int age) {
super();
this.name = name;
this.age = age;
@@ -4,10 +4,10 @@ import io.vavr.collection.Seq;
import io.vavr.control.Validation;
class PersonValidator {
String NAME_ERR = "Invalid characters in name: ";
String AGE_ERR = "Age must be at least 0";
private static final String NAME_ERR = "Invalid characters in name: ";
private static final String AGE_ERR = "Age must be at least 0";
public Validation<Seq<String>, Person> validatePerson(String name, int age) {
Validation<Seq<String>, Person> validatePerson(String name, int age) {
return Validation.combine(validateName(name), validateAge(age)).ap(Person::new);
}
@@ -5,14 +5,14 @@ import com.baeldung.vavr.exception.handling.client.HttpClient;
import com.baeldung.vavr.exception.handling.client.Response;
import io.vavr.control.Try;
public class VavrTry {
class VavrTry {
private final HttpClient httpClient;
public VavrTry(HttpClient httpClient) {
VavrTry(HttpClient httpClient) {
this.httpClient = httpClient;
}
public Try<Response> getResponse() {
Try<Response> getResponse() {
return Try.of(httpClient::call);
}
}