### Question:
Eithers { public static <S, T> Iterable<T> rights(Iterable<Either<S, T>> eithers) { return map(filter(eithers, Eithers.<S, T>isRight()), Eithers.<S, T>toRight()); } 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();  }### Answer:
@Test public void shouldCollapseIterableOfEithersOntoTheirRights() 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<Integer> rights = Eithers.rights(eithers); assertThat(materialize(rights), hasOnlyItemsInAnyOrder(3, 4)); }
@Test(expected = NullPointerException.class) public void shouldThrowANullPointerExceptionIfIterableSuppliedToRightsIsNull() throws Exception { Iterable<Either<String, Integer>> input = null; Eithers.rights(input); }