/*
 * Copyright (C) 2014  Ohm Data
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Affero General Public License as
 *  published by the Free Software Foundation, either version 3 of the
 *  License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Affero General Public License for more details.
 *
 *  You should have received a copy of the GNU Affero General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package c5db;

import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;

import java.util.List;

public class CollectionMatchers {
  public static <T extends Comparable<T>> Matcher<List<T>> isNondecreasing() {
    return new TypeSafeMatcher<List<T>>() {
      @Override
      protected boolean matchesSafely(List<T> list) {
        for (int i = 1; i < list.size(); i++) {
          if (list.get(i).compareTo(list.get(i - 1)) < 0) {
            return false;
          }
        }
        return true;
      }

      @Override
      public void describeTo(Description description) {
        description.appendText("a list whose elements are nondecreasing");
      }
    };
  }
}

@@ -828,16 +828,45 @@
 tcher;%0A%0A
+import java.util.Collection;%0A
 import j
@@ -1459,11 +1459,433 @@
   %7D;%0A  %7D
+%0A%0A  public static %3CT%3E Matcher%3CT%3E isIn(Collection%3CT%3E collection) %7B%0A    return new TypeSafeMatcher%3CT%3E() %7B%0A      @Override%0A      protected boolean matchesSafely(T item) %7B%0A        return collection.contains(item);%0A      %7D%0A%0A      @Override%0A      public void describeTo(Description description) %7B%0A        description.appendText(%22an item contained within the collection %22)%0A            .appendValue(collection);%0A      %7D%0A    %7D;%0A  %7D
 %0A%7D%0A

Add new collection matcher