committed by
GitHub
parent
6e994240f7
commit
ef34fc6576
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user