// License: GPL. For details, see LICENSE file. package org; import org.hamcrest.Description; import org.hamcrest.Matcher; import org.hamcrest.TypeSafeMatcher; import org.junit.Ignore; import org.openstreetmap.josm.tools.Predicate; import java.util.Collection; @Ignore("no test") public class CustomMatchers { public static Matcher forPredicate(final Predicate predicate) { return new TypeSafeMatcher() { @Override protected boolean matchesSafely(T item) { return predicate.evaluate(item); } @Override public void describeTo(Description description) { description.appendValue(predicate); } }; } public static Matcher> hasSize(final int size) { return new TypeSafeMatcher>() { @Override protected boolean matchesSafely(Collection collection) { return collection != null && collection.size() == size; } @Override public void describeTo(Description description) { description.appendText("hasSize(").appendValue(size).appendText(")"); } }; } public static Matcher> isEmpty() { return new TypeSafeMatcher>() { @Override protected boolean matchesSafely(Collection collection) { return collection != null && collection.isEmpty(); } @Override public void describeTo(Description description) { description.appendText("isEmpty()"); } }; } }