1package org.junit.internal.matchers;
2
3import static org.hamcrest.CoreMatchers.not;
4import static org.junit.internal.matchers.IsCollectionContaining.hasItem;
5import org.hamcrest.BaseMatcher;
6import org.hamcrest.Description;
7import org.hamcrest.Matcher;
8
9public class Each {
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