• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package org.junit.internal.matchers;
2 
3 import static org.hamcrest.CoreMatchers.not;
4 import static org.junit.internal.matchers.IsCollectionContaining.hasItem;
5 import org.hamcrest.BaseMatcher;
6 import org.hamcrest.Description;
7 import org.hamcrest.Matcher;
8 
9 public class Each {
each(final Matcher<T> individual)10 	public static <T> Matcher<Iterable<T>> each(final Matcher<T> individual) {
11 		final Matcher<Iterable<T>> allItemsAre = not(hasItem(not(individual)));
12 
13 		return new BaseMatcher<Iterable<T>>() {
14 			public boolean matches(Object item) {
15 				return allItemsAre.matches(item);
16 			}
17 
18 			public void describeTo(Description description) {
19 				description.appendText("each ");
20 				individual.describeTo(description);
21 			}
22 		};
23 	}
24 }
25