@Test public void shouldReturnAMapperThatMapsAnEitherToItsLeft() throws Exception { String expected = "left"; Either<String, Integer> either = Either.left("left"); Mapper<? super Either<String, Integer>, String> mapper = Eithers.toLeft(); String actual = mapper.map(either); assertThat(actual, is(expected)); }
public static <S, T> Mapper<? super Either<S, T>, S> toLeft() { return new Mapper<Either<S, T>, S>() { @Override public S map(Either<S, T> either) { return either.getLeft(); } }; }
Eithers { public static <S, T> Mapper<? super Either<S, T>, S> toLeft() { return new Mapper<Either<S, T>, S>() { @Override public S map(Either<S, T> either) { return either.getLeft(); } }; } }
Eithers { public static <S, T> Mapper<? super Either<S, T>, S> toLeft() { return new Mapper<Either<S, T>, S>() { @Override public S map(Either<S, T> either) { return either.getLeft(); } }; } private  Eithers(); }
Eithers { public static <S, T> Mapper<? super Either<S, T>, S> toLeft() { return new Mapper<Either<S, T>, S>() { @Override public S map(Either<S, T> either) { return either.getLeft(); } }; } private  Eithers(); static Iterable<T> rights(Iterable<Either<S, T>> eithers); static Iterable<S> lefts(Iterable<Either<S, T>> eithers); static Mapper<? super Either<S, T>, T> toRight(); static Mapper<? super Either<S, T>, S> toLeft(); static Predicate<? super Either<S, T>> isRight(); static Predicate<? super Either<S, T>> isLeft(); }
Eithers { public static <S, T> Mapper<? super Either<S, T>, S> toLeft() { return new Mapper<Either<S, T>, S>() { @Override public S map(Either<S, T> either) { return either.getLeft(); } }; } private  Eithers(); static Iterable<T> rights(Iterable<Either<S, T>> eithers); static Iterable<S> lefts(Iterable<Either<S, T>> eithers); static Mapper<? super Either<S, T>, T> toRight(); static Mapper<? super Either<S, T>, S> toLeft(); static Predicate<? super Either<S, T>> isRight(); static Predicate<? super Either<S, T>> isLeft();  }