[JAVA-630] vavr-2 module

* Creation

* Moved https://www.baeldung.com/vavr-either code

* Moved https://www.baeldung.com/java-vavr code
This commit is contained in:
dupirefr
2020-04-17 21:25:03 +02:00
parent 87ac7a74be
commit ffc79e7edd
7 changed files with 40 additions and 4 deletions
@@ -1,37 +0,0 @@
package com.baeldung.vavr.either;
import java.util.HashMap;
import java.util.Map;
import io.vavr.control.Either;
public class EitherDemo {
public static Object[] computeWithoutEitherUsingArray(int marks) {
Object[] results = new Object[2];
if (marks < 85) {
results[0] = "Marks not acceptable";
} else {
results[1] = marks;
}
return results;
}
public static Map<String, Object> computeWithoutEitherUsingMap(int marks) {
Map<String, Object> results = new HashMap<>();
if (marks < 85) {
results.put("FAILURE", "Marks not acceptable");
} else {
results.put("SUCCESS", marks);
}
return results;
}
static Either<String, Integer> computeWithEither(int marks) {
if (marks < 85) {
return Either.left("Marks not acceptable");
} else {
return Either.right(marks);
}
}
}