@@ -0,0 +1,2542 @@
+/*%0A * Copyright 2012-2015 JetBrains s.r.o%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *   http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage jetbrains.jetpad.base;%0A%0Aimport java.util.Objects;%0A%0Apublic abstract class Either%3CL, R%3E %7B%0A%0A  public static %3CL, R%3E Either%3CL, R%3E left(L left) %7B%0A    return new Left%3C%3E(left);%0A  %7D%0A%0A  public static %3CL, R%3E Either%3CL, R%3E right(R right) %7B%0A    return new Right%3C%3E(right);%0A  %7D%0A%0A  public abstract boolean isLeft();%0A%0A  public boolean isRight() %7B%0A    return !isLeft();%0A  %7D%0A%0A  public abstract L getLeft();%0A  public abstract R getRight();%0A%0A  private static class Left%3CL, R%3E extends Either%3CL, R%3E %7B%0A    private L myLeft;%0A%0A    private Left(L left) %7B%0A      myLeft = left;%0A    %7D%0A%0A    @Override%0A    public boolean isLeft() %7B%0A      return true;%0A    %7D%0A%0A    @Override%0A    public L getLeft() %7B%0A      return myLeft;%0A    %7D%0A%0A    @Override%0A    public R getRight() %7B%0A      throw new UnsupportedOperationException();%0A    %7D%0A%0A%0A    @Override%0A    public boolean equals(Object obj) %7B%0A      if (!(obj instanceof Left)) return false;%0A      return Objects.equals(myLeft, ((Left) obj).myLeft);%0A    %7D%0A%0A    @Override%0A    public int hashCode() %7B%0A      if (myLeft == null) return 3;%0A      return 239 * myLeft.hashCode();%0A    %7D%0A%0A    @Override%0A    public String toString() %7B%0A      return %22L(%22 + myLeft + %22)%22;%0A    %7D%0A  %7D%0A%0A  private static class Right%3CL, R%3E extends Either%3CL, R%3E %7B%0A    private R myRight;%0A%0A    private Right(R right) %7B%0A      myRight = right;%0A    %7D%0A%0A    @Override%0A    public boolean isLeft() %7B%0A      return false;%0A    %7D%0A%0A    @Override%0A    public L getLeft() %7B%0A      throw new UnsupportedOperationException();%0A    %7D%0A%0A    @Override%0A    public R getRight() %7B%0A      return myRight;%0A    %7D%0A%0A    @Override%0A    public boolean equals(Object obj) %7B%0A      if (!(obj instanceof Right)) return false;%0A      return Objects.equals(myRight, ((Right) obj).myRight);%0A    %7D%0A%0A    @Override%0A    public int hashCode() %7B%0A      if (myRight == null) return 1;%0A      return 31 * myRight.hashCode();%0A    %7D%0A%0A    @Override%0A    public String toString() %7B%0A      return %22R(%22 + myRight + %22)%22;%0A    %7D%0A  %7D%0A%7D%0A

move either