Skip to content

Commit 70680ea

Browse files
lor6pivovarit
authored andcommitted
vavr refactor (eugenp#1871)
* vavr refactor * small fix
1 parent 7728d58 commit 70680ea

15 files changed

Lines changed: 139 additions & 135 deletions

File tree

‎javaslang/README.md‎

Lines changed: 0 additions & 5 deletions
This file was deleted.

‎javaslang/src/main/java/com/baeldung/javaslang/exception/handling/JavaslangTry.java‎

Lines changed: 0 additions & 18 deletions
This file was deleted.

‎vavr/README.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
### Relevant Articles:
2+
- [Introduction to Vavr](http://www.baeldung.com/javaslang)
3+
- [Guide to Try in Vavr](http://www.baeldung.com/javaslang-try)
4+
- [Guide to Pattern Matching in Vavr](http://www.baeldung.com/javaslang-pattern-matching)
5+
- [Property Testing Example With Vavr](http://www.baeldung.com/javaslang-property-testing)

javaslang/pom.xml renamed to vavr/pom.xml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,33 @@
22
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.baeldung</groupId>
5-
<artifactId>javaslang</artifactId>
5+
<artifactId>vavr</artifactId>
66
<version>1.0</version>
7-
<name>javaslang</name>
8-
9-
<parent>
7+
<name>vavr</name>
8+
9+
<parent>
1010
<groupId>com.baeldung</groupId>
1111
<artifactId>parent-modules</artifactId>
1212
<version>1.0.0-SNAPSHOT</version>
1313
</parent>
1414

1515
<dependencies>
1616
<dependency>
17-
<groupId>io.javaslang</groupId>
18-
<artifactId>javaslang</artifactId>
19-
<version>2.1.0-alpha</version>
17+
<groupId>io.vavr</groupId>
18+
<artifactId>vavr-test</artifactId>
19+
<version>${vavr.version}</version>
2020
</dependency>
21+
2122
<dependency>
22-
<groupId>io.javaslang</groupId>
23-
<artifactId>javaslang-test</artifactId>
24-
<version>${javaslang.test.version}</version>
23+
<groupId>junit</groupId>
24+
<artifactId>junit</artifactId>
25+
<version>${junit.version}</version>
2526
</dependency>
2627
</dependencies>
2728

2829
<properties>
29-
<javaslang.test.version>2.0.5</javaslang.test.version>
30+
<vavr.version>0.9.0</vavr.version>
31+
<junit.version>4.12</junit.version>
3032
</properties>
3133

3234
</project>

javaslang/src/main/java/com/baeldung/javaslang/Person.java renamed to vavr/src/main/java/com/baeldung/vavr/Person.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.baeldung.javaslang;
1+
package com.baeldung.vavr;
22

33
public class Person {
44
private String name;

javaslang/src/main/java/com/baeldung/javaslang/PersonValidator.java renamed to vavr/src/main/java/com/baeldung/vavr/PersonValidator.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
package com.baeldung.javaslang;
1+
package com.baeldung.vavr;
22

3-
import javaslang.collection.List;
4-
import javaslang.control.Validation;
3+
import io.vavr.collection.Seq;
4+
import io.vavr.control.Validation;
55

66
class PersonValidator {
77
String NAME_ERR = "Invalid characters in name: ";
88
String AGE_ERR = "Age must be at least 0";
99

10-
public Validation<List<String>, Person> validatePerson(String name, int age) {
10+
public Validation<Seq<String>, Person> validatePerson(String name, int age) {
1111
return Validation.combine(validateName(name), validateAge(age)).ap(Person::new);
1212
}
1313

javaslang/src/main/java/com/baeldung/javaslang/exception/handling/JavaTryCatch.java renamed to vavr/src/main/java/com/baeldung/vavr/exception/handling/JavaTryCatch.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
package com.baeldung.javaslang.exception.handling;
1+
package com.baeldung.vavr.exception.handling;
22

3-
import com.baeldung.javaslang.exception.handling.client.ClientException;
4-
import com.baeldung.javaslang.exception.handling.client.HttpClient;
5-
import com.baeldung.javaslang.exception.handling.client.Response;
3+
import com.baeldung.vavr.exception.handling.client.ClientException;
4+
import com.baeldung.vavr.exception.handling.client.HttpClient;
5+
import com.baeldung.vavr.exception.handling.client.Response;
66

77
public class JavaTryCatch {
88
private HttpClient httpClient;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.baeldung.vavr.exception.handling;
2+
3+
4+
import com.baeldung.vavr.exception.handling.client.HttpClient;
5+
import com.baeldung.vavr.exception.handling.client.Response;
6+
import io.vavr.control.Try;
7+
8+
public class VavrTry {
9+
private final HttpClient httpClient;
10+
11+
public VavrTry(HttpClient httpClient) {
12+
this.httpClient = httpClient;
13+
}
14+
15+
public Try<Response> getResponse() {
16+
return Try.of(httpClient::call);
17+
}
18+
}

javaslang/src/main/java/com/baeldung/javaslang/exception/handling/client/ClientException.java renamed to vavr/src/main/java/com/baeldung/vavr/exception/handling/client/ClientException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.baeldung.javaslang.exception.handling.client;
1+
package com.baeldung.vavr.exception.handling.client;
22

33

44
public class ClientException extends Exception {

javaslang/src/main/java/com/baeldung/javaslang/exception/handling/client/HttpClient.java renamed to vavr/src/main/java/com/baeldung/vavr/exception/handling/client/HttpClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.baeldung.javaslang.exception.handling.client;
1+
package com.baeldung.vavr.exception.handling.client;
22

33

44
public interface HttpClient {

0 commit comments

Comments
 (0)