package com.autonomy.abc.matchers;

import org.hamcrest.Matcher;

import java.util.List;

import static org.hamcrest.Matchers.hasItems;

public class CommonMatchers {
    private CommonMatchers() {}

    public static Matcher<Iterable<String>> containsItems(List<String> list) {
        return hasItems(list.toArray(new String[list.size()]));
    }
}

@@ -53,17 +53,144 @@
 est.
-Matcher;%0A
+Description;%0Aimport org.hamcrest.Matcher;%0Aimport org.hamcrest.TypeSafeMatcher;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.Comparator;
 %0Aimp
@@ -246,24 +246,17 @@
 atchers.
-hasItems
+*
 ;%0A%0Apubli
@@ -330,16 +330,20 @@
 c static
+ %3CT%3E
  Matcher
@@ -356,114 +356,1643 @@
 ble%3C
-String%3E%3E containsItems(List%3CString%3E list) %7B%0A        return hasItems(list.toArray(new String%5Blist.size()%5D))
+T%3E%3E containsItems(List%3C? extends T%3E list) %7B%0A        @SuppressWarnings(%22unchecked%22)%0A        T%5B%5D empties = (T%5B%5D) new Object%5Blist.size()%5D;%0A        return hasItems(list.toArray(empties));%0A    %7D%0A%0A    public static %3CT%3E Matcher%3CIterable%3C? super T%3E%3E containsItems(final List%3C? extends T%3E list, final Comparator%3C? super T%3E comparator) %7B%0A        return new TypeSafeMatcher%3CIterable%3C? super T%3E%3E() %7B%0A            @Override%0A            protected boolean matchesSafely(Iterable%3C? super T%3E item) %7B%0A                for (T element : list) %7B%0A                    if (!containsItem(element, comparator).matches(item)) %7B%0A                        return false;%0A                    %7D%0A                %7D%0A                return true;%0A            %7D%0A%0A            @Override%0A            public void describeTo(Description description) %7B%0A                description.appendText(%22a collection containing all of %22).appendValueList(%22%7B%22, %22, %22, %22%7D%22, list);%0A            %7D%0A        %7D;%0A    %7D%0A%0A    public static %3CT%3E Matcher%3CIterable%3C? super T%3E%3E containsItem(final T value, final Comparator%3C? super T%3E comparator) %7B%0A        return hasItem(comparesEqualTo(value, comparator));%0A    %7D%0A%0A    public static %3CT%3E Matcher%3CT%3E comparesEqualTo(final T value, final Comparator%3C? super T%3E comparator) %7B%0A        return new TypeSafeMatcher%3CT%3E() %7B%0A            @Override%0A            protected boolean matchesSafely(T item) %7B%0A                return comparator.compare(item, value) == 0;%0A            %7D%0A%0A            @Override%0A            public void describeTo(Description description) %7B%0A                description.appendText(%22an item comparing equal to %22).appendValue(value);%0A            %7D%0A        %7D
 ;%0A  

Add generic matchers