]> WPIA git - gigi.git/blob - tests/club/wpia/gigi/testUtils/ArrayContains.java
add: implement password change log
[gigi.git] / tests / club / wpia / gigi / testUtils / ArrayContains.java
1 package club.wpia.gigi.testUtils;
2
3 import org.hamcrest.BaseMatcher;
4 import org.hamcrest.Description;
5 import org.hamcrest.Matcher;
6
7 public class ArrayContains<T> extends BaseMatcher<T[]> {
8
9     Matcher<T> containee;
10
11     public ArrayContains(Matcher<T> containee) {
12         this.containee = containee;
13     }
14
15     @Override
16     public boolean matches(Object item) {
17         Object[] array = (Object[]) item;
18         for (Object t : array) {
19             if (containee.matches(t)) {
20                 return true;
21             }
22         }
23         return false;
24     }
25
26     @Override
27     public void describeTo(Description description) {
28         description.appendText("contains an element that:");
29         containee.describeTo(description);
30     }
31
32     public static <T> ArrayContains<T> contains(final Matcher<T> element) {
33         return new ArrayContains<T>(element);
34     }
35 }