Matchers { static <P> Matcher[] toArray(Iterable<? extends Matcher<P>> matchers) { if (matchers == null) throw new NullPointerException("matchers == null"); if (matchers instanceof Collection) { return (Matcher[]) ((Collection) matchers).toArray(new Matcher[0]); } List<Matcher<P>> result = new ArrayList<>(); for (Matcher<P> matcher : matchers) result.add(matcher); return result.toArray(new Matcher[0]); }  static Matcher<P> alwaysMatch(); static Matcher<P> neverMatch(); static Matcher<P> and(Iterable<? extends Matcher<P>> matchers); static Matcher<P> and(Matcher<P>... matchers); static Matcher<P> or(Iterable<? extends Matcher<P>> matchers); static Matcher<P> or(Matcher<P>... matchers);  }
@Test public void toArray_list() { Matcher<Void> one = b -> true; Matcher<Void> two = b -> false; Matcher<Void> three = b -> true; assertThat(Matchers.toArray(asList(one, two, three))) .containsExactly(one, two, three); }
@Test public void toArray_iterable() { Matcher<Void> one = b -> true; Matcher<Void> two = b -> false; Matcher<Void> three = b -> true; assertThat(Matchers.toArray(() -> asList(one, two, three).iterator())) .containsExactly(one, two, three); }