@@ -0,0 +1,2014 @@
+package yokohama.unit.util;%0D%0A%0D%0Aimport java.util.Optional;%0D%0Aimport java.util.function.Function;%0D%0Aimport java.util.stream.Stream;%0D%0Aimport lombok.EqualsAndHashCode;%0D%0Aimport lombok.Value;%0D%0A%0D%0Aabstract public class Either%3CT, U%3E %7B%0D%0A    public abstract %3CV%3E V match(Function%3CT, V%3E left, Function%3CU, V%3E right);%0D%0A    public abstract boolean isLeft();%0D%0A    public abstract boolean isRight();%0D%0A%0D%0A    public Optional%3CT%3E leftOptional() %7B%0D%0A        return this.match(l -%3E Optional.of(l), r -%3E Optional.%3CT%3Eempty());%0D%0A    %7D%0D%0A%0D%0A    public Optional%3CU%3E rightOptional() %7B%0D%0A        return this.match(l -%3E Optional.%3CU%3Eempty(), r -%3E Optional.of(r));%0D%0A    %7D%0D%0A%0D%0A    public Stream%3CT%3E leftStream() %7B%0D%0A        return this.match(l -%3E Stream.of(l), r -%3E Stream.%3CT%3Eempty());%0D%0A    %7D%0D%0A%0D%0A    public Stream%3CU%3E rightStream() %7B%0D%0A        return this.match(l -%3E Stream.%3CU%3Eempty(), r -%3E Stream.of(r));%0D%0A    %7D%0D%0A%0D%0A    public static %3CT, U%3E Either%3CT, U%3E left(T value) %7B return new Left%3C%3E(value); %7D%0D%0A    public static %3CT, U%3E Either%3CT, U%3E right(U value) %7B return new Right%3C%3E(value); %7D%0D%0A%0D%0A    @Value%0D%0A    @EqualsAndHashCode(callSuper=false)%0D%0A    private static class Left%3CT, U%3E extends Either%3CT, U%3E %7B%0D%0A        private final T value;%0D%0A%0D%0A        @Override%0D%0A        public %3CV%3E V match(Function%3CT, V%3E left, Function%3CU, V%3E right) %7B%0D%0A            return left.apply(value);%0D%0A        %7D%0D%0A%0D%0A        @Override%0D%0A        public boolean isLeft() %7B%0D%0A            return true;%0D%0A        %7D%0D%0A%0D%0A        @Override%0D%0A        public boolean isRight() %7B%0D%0A            return false;%0D%0A        %7D%0D%0A    %7D%0D%0A%0D%0A    @Value%0D%0A    @EqualsAndHashCode(callSuper=false)%0D%0A    private static class Right%3CT, U%3E extends Either%3CT, U%3E %7B%0D%0A        private final U value;%0D%0A%0D%0A        @Override%0D%0A        public %3CV%3E V match(Function%3CT, V%3E left, Function%3CU, V%3E right) %7B%0D%0A            return right.apply(value);%0D%0A        %7D%0D%0A%0D%0A        @Override%0D%0A        public boolean isLeft() %7B%0D%0A            return false;%0D%0A        %7D%0D%0A%0D%0A        @Override%0D%0A        public boolean isRight() %7B%0D%0A            return true;%0D%0A        %7D%0D%0A    %7D%0D%0A%7D%0D%0A

Add Either class