@@ -0,0 +1,1192 @@
+package fp;%0A%0Aimport java.util.Optional;%0Aimport java.util.function.Consumer;%0Aimport java.util.function.Function;%0A%0Apublic final class Either%3CL,R%3E%0A%7B%0A    public static %3CL,R%3E Either%3CL,R%3E left(L value) %7B%0A        return new Either%3C%3E(Optional.of(value), Optional.empty());%0A    %7D%0A    public static %3CL,R%3E Either%3CL,R%3E right(R value) %7B%0A        return new Either%3C%3E(Optional.empty(), Optional.of(value));%0A    %7D%0A    private final Optional%3CL%3E left;%0A    private final Optional%3CR%3E right;%0A    private Either(Optional%3CL%3E l, Optional%3CR%3E r) %7B%0A      left=l;%0A      right=r;%0A    %7D%0A    public %3CT%3E T map(%0A        Function%3C? super L, ? extends T%3E lFunc,%0A        Function%3C? super R, ? extends T%3E rFunc)%0A    %7B%0A        return left.%3CT%3Emap(lFunc).orElseGet(()-%3Eright.map(rFunc).get());%0A    %7D%0A    public %3CT%3E Either%3CT,R%3E mapLeft(Function%3C? super L, ? extends T%3E lFunc)%0A    %7B%0A        return new Either%3C%3E(left.map(lFunc),right);%0A    %7D%0A    public %3CT%3E Either%3CL,T%3E mapRight(Function%3C? super R, ? extends T%3E rFunc)%0A    %7B%0A        return new Either%3C%3E(left, right.map(rFunc));%0A    %7D%0A    public void apply(Consumer%3C? super L%3E lFunc, Consumer%3C? super R%3E rFunc)%0A    %7B%0A        left.ifPresent(lFunc);%0A        right.ifPresent(rFunc);%0A    %7D%0A%7D%0A

Add Java Either