Either { public L getLeft() { if (!isLeft()) { throw new UnsupportedOperationException(); } return left; } private  Either(L left, R right); L getLeft(); R getRight(); boolean isLeft(); boolean isRight(); static Either<L, R> left(L left); static Either<L, R> right(R right); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void getLeftPositive() { assertEquals("ko", ko.getLeft()); }
@Test(expected = UnsupportedOperationException.class) public void getLeftNegative() { ok.getLeft(); }