Either { private Either() { } private  Either(); abstract LeftProjection<A, B> left(); abstract RightProjection<A, B> right(); abstract X fold(Match<A, B, X> visitor); abstract X fold(Function<? super A, ? extends X> left, Function<? super B, ? extends X> right); abstract boolean isLeft(); abstract boolean isRight(); static Either<A, B> left(final A left); static Either<A, B> right(final B right);  }
@Test public void testEither() { assertTrue(left("a").isLeft()); assertTrue(right("a").isRight()); Either<String, Integer> a = left("error"); assertEquals("error", a.left().value()); Either<String, Integer> b = right(1); assertEquals(new Integer(1), b.right().value()); }