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