@Test public void shouldCollapseIterableOfEithersOntoTheirLefts() throws Exception { Either<String, Integer> firstEither = Either.left("first"); Either<String, Integer> secondEither = Either.left("second"); Either<String, Integer> thirdEither = Either.right(3); Either<String, Integer> fourthEither = Either.right(4); Iterable<Either<String, Integer>> eithers = iterableWith(firstEither, secondEither, thirdEither, fourthEither); Iterable<String> lefts = Eithers.lefts(eithers); assertThat(materialize(lefts), hasOnlyItemsInAnyOrder("first", "second")); }
public static <S, T> Iterable<S> lefts(Iterable<Either<S, T>> eithers) { return map(filter(eithers, Eithers.<S, T>isLeft()), Eithers.<S, T>toLeft()); }
Eithers { public static <S, T> Iterable<S> lefts(Iterable<Either<S, T>> eithers) { return map(filter(eithers, Eithers.<S, T>isLeft()), Eithers.<S, T>toLeft()); } }
Eithers { public static <S, T> Iterable<S> lefts(Iterable<Either<S, T>> eithers) { return map(filter(eithers, Eithers.<S, T>isLeft()), Eithers.<S, T>toLeft()); } private  Eithers(); }
Eithers { public static <S, T> Iterable<S> lefts(Iterable<Either<S, T>> eithers) { return map(filter(eithers, Eithers.<S, T>isLeft()), Eithers.<S, T>toLeft()); } 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> Iterable<S> lefts(Iterable<Either<S, T>> eithers) { return map(filter(eithers, Eithers.<S, T>isLeft()), Eithers.<S, T>toLeft()); } 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();  }