001    // Generated source.
002    package org.hamcrest;
003    
004    public class CoreMatchers {
005    
006      /**
007       * Creates a matcher that matches if the examined object matches <b>ALL</b> of the specified matchers.
008       * <p/>
009       * For example:
010       * <pre>assertThat("myValue", allOf(startsWith("my"), containsString("Val")))</pre>
011       */
012      public static <T> org.hamcrest.Matcher<T> allOf(java.lang.Iterable<org.hamcrest.Matcher<? super T>> matchers) {
013        return org.hamcrest.core.AllOf.<T>allOf(matchers);
014      }
015    
016      /**
017       * Creates a matcher that matches if the examined object matches <b>ALL</b> of the specified matchers.
018       * <p/>
019       * For example:
020       * <pre>assertThat("myValue", allOf(startsWith("my"), containsString("Val")))</pre>
021       */
022      public static <T> org.hamcrest.Matcher<T> allOf(org.hamcrest.Matcher<? super T>... matchers) {
023        return org.hamcrest.core.AllOf.<T>allOf(matchers);
024      }
025    
026      /**
027       * Creates a matcher that matches if the examined object matches <b>ALL</b> of the specified matchers.
028       * <p/>
029       * For example:
030       * <pre>assertThat("myValue", allOf(startsWith("my"), containsString("Val")))</pre>
031       */
032      public static <T> org.hamcrest.Matcher<T> allOf(org.hamcrest.Matcher<? super T> first, org.hamcrest.Matcher<? super T> second) {
033        return org.hamcrest.core.AllOf.<T>allOf(first, second);
034      }
035    
036      /**
037       * Creates a matcher that matches if the examined object matches <b>ALL</b> of the specified matchers.
038       * <p/>
039       * For example:
040       * <pre>assertThat("myValue", allOf(startsWith("my"), containsString("Val")))</pre>
041       */
042      public static <T> org.hamcrest.Matcher<T> allOf(org.hamcrest.Matcher<? super T> first, org.hamcrest.Matcher<? super T> second, org.hamcrest.Matcher<? super T> third) {
043        return org.hamcrest.core.AllOf.<T>allOf(first, second, third);
044      }
045    
046      /**
047       * Creates a matcher that matches if the examined object matches <b>ALL</b> of the specified matchers.
048       * <p/>
049       * For example:
050       * <pre>assertThat("myValue", allOf(startsWith("my"), containsString("Val")))</pre>
051       */
052      public static <T> org.hamcrest.Matcher<T> allOf(org.hamcrest.Matcher<? super T> first, org.hamcrest.Matcher<? super T> second, org.hamcrest.Matcher<? super T> third, org.hamcrest.Matcher<? super T> fourth) {
053        return org.hamcrest.core.AllOf.<T>allOf(first, second, third, fourth);
054      }
055    
056      /**
057       * Creates a matcher that matches if the examined object matches <b>ALL</b> of the specified matchers.
058       * <p/>
059       * For example:
060       * <pre>assertThat("myValue", allOf(startsWith("my"), containsString("Val")))</pre>
061       */
062      public static <T> org.hamcrest.Matcher<T> allOf(org.hamcrest.Matcher<? super T> first, org.hamcrest.Matcher<? super T> second, org.hamcrest.Matcher<? super T> third, org.hamcrest.Matcher<? super T> fourth, org.hamcrest.Matcher<? super T> fifth) {
063        return org.hamcrest.core.AllOf.<T>allOf(first, second, third, fourth, fifth);
064      }
065    
066      /**
067       * Creates a matcher that matches if the examined object matches <b>ALL</b> of the specified matchers.
068       * <p/>
069       * For example:
070       * <pre>assertThat("myValue", allOf(startsWith("my"), containsString("Val")))</pre>
071       */
072      public static <T> org.hamcrest.Matcher<T> allOf(org.hamcrest.Matcher<? super T> first, org.hamcrest.Matcher<? super T> second, org.hamcrest.Matcher<? super T> third, org.hamcrest.Matcher<? super T> fourth, org.hamcrest.Matcher<? super T> fifth, org.hamcrest.Matcher<? super T> sixth) {
073        return org.hamcrest.core.AllOf.<T>allOf(first, second, third, fourth, fifth, sixth);
074      }
075    
076      /**
077       * Creates a matcher that matches if the examined object matches <b>ANY</b> of the specified matchers.
078       * <p/>
079       * For example:
080       * <pre>assertThat("myValue", anyOf(startsWith("foo"), containsString("Val")))</pre>
081       */
082      public static <T> org.hamcrest.core.AnyOf<T> anyOf(java.lang.Iterable<org.hamcrest.Matcher<? super T>> matchers) {
083        return org.hamcrest.core.AnyOf.<T>anyOf(matchers);
084      }
085    
086      /**
087       * Creates a matcher that matches if the examined object matches <b>ANY</b> of the specified matchers.
088       * <p/>
089       * For example:
090       * <pre>assertThat("myValue", anyOf(startsWith("foo"), containsString("Val")))</pre>
091       */
092      public static <T> org.hamcrest.core.AnyOf<T> anyOf(org.hamcrest.Matcher<T> first, org.hamcrest.Matcher<? super T> second, org.hamcrest.Matcher<? super T> third) {
093        return org.hamcrest.core.AnyOf.<T>anyOf(first, second, third);
094      }
095    
096      /**
097       * Creates a matcher that matches if the examined object matches <b>ANY</b> of the specified matchers.
098       * <p/>
099       * For example:
100       * <pre>assertThat("myValue", anyOf(startsWith("foo"), containsString("Val")))</pre>
101       */
102      public static <T> org.hamcrest.core.AnyOf<T> anyOf(org.hamcrest.Matcher<T> first, org.hamcrest.Matcher<? super T> second, org.hamcrest.Matcher<? super T> third, org.hamcrest.Matcher<? super T> fourth) {
103        return org.hamcrest.core.AnyOf.<T>anyOf(first, second, third, fourth);
104      }
105    
106      /**
107       * Creates a matcher that matches if the examined object matches <b>ANY</b> of the specified matchers.
108       * <p/>
109       * For example:
110       * <pre>assertThat("myValue", anyOf(startsWith("foo"), containsString("Val")))</pre>
111       */
112      public static <T> org.hamcrest.core.AnyOf<T> anyOf(org.hamcrest.Matcher<T> first, org.hamcrest.Matcher<? super T> second, org.hamcrest.Matcher<? super T> third, org.hamcrest.Matcher<? super T> fourth, org.hamcrest.Matcher<? super T> fifth) {
113        return org.hamcrest.core.AnyOf.<T>anyOf(first, second, third, fourth, fifth);
114      }
115    
116      /**
117       * Creates a matcher that matches if the examined object matches <b>ANY</b> of the specified matchers.
118       * <p/>
119       * For example:
120       * <pre>assertThat("myValue", anyOf(startsWith("foo"), containsString("Val")))</pre>
121       */
122      public static <T> org.hamcrest.core.AnyOf<T> anyOf(org.hamcrest.Matcher<T> first, org.hamcrest.Matcher<? super T> second, org.hamcrest.Matcher<? super T> third, org.hamcrest.Matcher<? super T> fourth, org.hamcrest.Matcher<? super T> fifth, org.hamcrest.Matcher<? super T> sixth) {
123        return org.hamcrest.core.AnyOf.<T>anyOf(first, second, third, fourth, fifth, sixth);
124      }
125    
126      /**
127       * Creates a matcher that matches if the examined object matches <b>ANY</b> of the specified matchers.
128       * <p/>
129       * For example:
130       * <pre>assertThat("myValue", anyOf(startsWith("foo"), containsString("Val")))</pre>
131       */
132      public static <T> org.hamcrest.core.AnyOf<T> anyOf(org.hamcrest.Matcher<T> first, org.hamcrest.Matcher<? super T> second) {
133        return org.hamcrest.core.AnyOf.<T>anyOf(first, second);
134      }
135    
136      /**
137       * Creates a matcher that matches if the examined object matches <b>ANY</b> of the specified matchers.
138       * <p/>
139       * For example:
140       * <pre>assertThat("myValue", anyOf(startsWith("foo"), containsString("Val")))</pre>
141       */
142      public static <T> org.hamcrest.core.AnyOf<T> anyOf(org.hamcrest.Matcher<? super T>... matchers) {
143        return org.hamcrest.core.AnyOf.<T>anyOf(matchers);
144      }
145    
146      /**
147       * Creates a matcher that matches when both of the specified matchers match the examined object.
148       * <p/>
149       * For example:
150       * <pre>assertThat("fab", both(containsString("a")).and(containsString("b")))</pre>
151       */
152      public static <LHS> org.hamcrest.core.CombinableMatcher.CombinableBothMatcher<LHS> both(org.hamcrest.Matcher<? super LHS> matcher) {
153        return org.hamcrest.core.CombinableMatcher.<LHS>both(matcher);
154      }
155    
156      /**
157       * Creates a matcher that matches when either of the specified matchers match the examined object.
158       * <p/>
159       * For example:
160       * <pre>assertThat("fan", either(containsString("a")).and(containsString("b")))</pre>
161       */
162      public static <LHS> org.hamcrest.core.CombinableMatcher.CombinableEitherMatcher<LHS> either(org.hamcrest.Matcher<? super LHS> matcher) {
163        return org.hamcrest.core.CombinableMatcher.<LHS>either(matcher);
164      }
165    
166      /**
167       * Wraps an existing matcher, overriding its description with that specified.  All other functions are
168       * delegated to the decorated matcher, including its mismatch description.
169       * <p/>
170       * For example:
171       * <pre>describedAs("a big decimal equal to %0", equalTo(myBigDecimal), myBigDecimal.toPlainString())</pre>
172       * 
173       * @param description
174       *     the new description for the wrapped matcher
175       * @param matcher
176       *     the matcher to wrap
177       * @param values
178       *     optional values to insert into the tokenised description
179       */
180      public static <T> org.hamcrest.Matcher<T> describedAs(java.lang.String description, org.hamcrest.Matcher<T> matcher, java.lang.Object... values) {
181        return org.hamcrest.core.DescribedAs.<T>describedAs(description, matcher, values);
182      }
183    
184      /**
185       * Creates a matcher for {@link Iterable}s that only matches when a single pass over the
186       * examined {@link Iterable} yields items that are all matched by the specified
187       * <code>itemMatcher</code>.
188       * <p/>
189       * For example:
190       * <pre>assertThat(Arrays.asList("bar", "baz"), everyItem(startsWith("ba")))</pre>
191       * 
192       * @param itemMatcher
193       *     the matcher to apply to every item provided by the examined {@link Iterable}
194       */
195      public static <U> org.hamcrest.Matcher<java.lang.Iterable<U>> everyItem(org.hamcrest.Matcher<U> itemMatcher) {
196        return org.hamcrest.core.Every.<U>everyItem(itemMatcher);
197      }
198    
199      /**
200       * A shortcut to the frequently used <code>is(equalTo(x))</code>.
201       * <p/>
202       * For example:
203       * <pre>assertThat(cheese, is(smelly))</pre>
204       * instead of:
205       * <pre>assertThat(cheese, is(equalTo(smelly)))</pre>
206       */
207      public static <T> org.hamcrest.Matcher<T> is(T value) {
208        return org.hamcrest.core.Is.<T>is(value);
209      }
210    
211      /**
212       * Decorates another Matcher, retaining its behaviour, but allowing tests
213       * to be slightly more expressive.
214       * <p/>
215       * For example:
216       * <pre>assertThat(cheese, is(equalTo(smelly)))</pre>
217       * instead of:
218       * <pre>assertThat(cheese, equalTo(smelly))</pre>
219       */
220      public static <T> org.hamcrest.Matcher<T> is(org.hamcrest.Matcher<T> matcher) {
221        return org.hamcrest.core.Is.<T>is(matcher);
222      }
223    
224      /**
225       * A shortcut to the frequently used <code>is(instanceOf(SomeClass.class))</code>.
226       * <p/>
227       * For example:
228       * <pre>assertThat(cheese, is(Cheddar.class))</pre>
229       * instead of:
230       * <pre>assertThat(cheese, is(instanceOf(Cheddar.class)))</pre>
231       * 
232       * @deprecated use isA(Class<T> type) instead.
233       */
234      public static <T> org.hamcrest.Matcher<T> is(java.lang.Class<T> type) {
235        return org.hamcrest.core.Is.<T>is(type);
236      }
237    
238      /**
239       * A shortcut to the frequently used <code>is(instanceOf(SomeClass.class))</code>.
240       * <p/>
241       * For example:
242       * <pre>assertThat(cheese, isA(Cheddar.class))</pre>
243       * instead of:
244       * <pre>assertThat(cheese, is(instanceOf(Cheddar.class)))</pre>
245       */
246      public static <T> org.hamcrest.Matcher<T> isA(java.lang.Class<T> type) {
247        return org.hamcrest.core.Is.<T>isA(type);
248      }
249    
250      /**
251       * Creates a matcher that always matches, regardless of the examined object.
252       */
253      public static org.hamcrest.Matcher<java.lang.Object> anything() {
254        return org.hamcrest.core.IsAnything.anything();
255      }
256    
257      /**
258       * Creates a matcher that always matches, regardless of the examined object, but describes
259       * itself with the specified {@link String}.
260       * 
261       * @param description
262       *     a meaningful {@link String} used when describing itself
263       */
264      public static org.hamcrest.Matcher<java.lang.Object> anything(java.lang.String description) {
265        return org.hamcrest.core.IsAnything.anything(description);
266      }
267    
268      /**
269       * Creates a matcher for {@link Iterable}s that only matches when a single pass over the
270       * examined {@link Iterable} yields at least one item that is equal to the specified
271       * <code>item</code>.  Whilst matching, the traversal of the examined {@link Iterable}
272       * will stop as soon as a matching item is found.
273       * <p/>
274       * For example:
275       * <pre>assertThat(Arrays.asList("foo", "bar"), hasItem("bar"))</pre>
276       * 
277       * @param item
278       *     the item to compare against the items provided by the examined {@link Iterable}
279       */
280      public static <T> org.hamcrest.Matcher<java.lang.Iterable<? super T>> hasItem(T item) {
281        return org.hamcrest.core.IsCollectionContaining.<T>hasItem(item);
282      }
283    
284      /**
285       * Creates a matcher for {@link Iterable}s that only matches when a single pass over the
286       * examined {@link Iterable} yields at least one item that is matched by the specified
287       * <code>itemMatcher</code>.  Whilst matching, the traversal of the examined {@link Iterable}
288       * will stop as soon as a matching item is found.
289       * <p/>
290       * For example:
291       * <pre>assertThat(Arrays.asList("foo", "bar"), hasItem(startsWith("ba")))</pre>
292       * 
293       * @param itemMatcher
294       *     the matcher to apply to items provided by the examined {@link Iterable}
295       */
296      public static <T> org.hamcrest.Matcher<java.lang.Iterable<? super T>> hasItem(org.hamcrest.Matcher<? super T> itemMatcher) {
297        return org.hamcrest.core.IsCollectionContaining.<T>hasItem(itemMatcher);
298      }
299    
300      /**
301       * Creates a matcher for {@link Iterable}s that matches when consecutive passes over the
302       * examined {@link Iterable} yield at least one item that is equal to the corresponding
303       * item from the specified <code>items</code>.  Whilst matching, each traversal of the
304       * examined {@link Iterable} will stop as soon as a matching item is found.
305       * <p/>
306       * For example:
307       * <pre>assertThat(Arrays.asList("foo", "bar", "baz"), hasItems("baz", "foo"))</pre>
308       * 
309       * @param items
310       *     the items to compare against the items provided by the examined {@link Iterable}
311       */
312      public static <T> org.hamcrest.Matcher<java.lang.Iterable<T>> hasItems(T... items) {
313        return org.hamcrest.core.IsCollectionContaining.<T>hasItems(items);
314      }
315    
316      /**
317       * Creates a matcher for {@link Iterable}s that matches when consecutive passes over the
318       * examined {@link Iterable} yield at least one item that is matched by the corresponding
319       * matcher from the specified <code>itemMatchers</code>.  Whilst matching, each traversal of
320       * the examined {@link Iterable} will stop as soon as a matching item is found.
321       * <p/>
322       * For example:
323       * <pre>assertThat(Arrays.asList("foo", "bar", "baz"), hasItems(endsWith("z"), endsWith("o")))</pre>
324       * 
325       * @param itemMatchers
326       *     the matchers to apply to items provided by the examined {@link Iterable}
327       */
328      public static <T> org.hamcrest.Matcher<java.lang.Iterable<T>> hasItems(org.hamcrest.Matcher<? super T>... itemMatchers) {
329        return org.hamcrest.core.IsCollectionContaining.<T>hasItems(itemMatchers);
330      }
331    
332      /**
333       * Creates a matcher that matches when the examined object is logically equal to the specified
334       * <code>operand</code>, as determined by calling the {@link java.lang.Object#equals} method on
335       * the <b>examined</b> object.
336       * 
337       * <p>If the specified operand is <code>null</code> then the created matcher will only match if
338       * the examined object's <code>equals</code> method returns <code>true</code> when passed a
339       * <code>null</code> (which would be a violation of the <code>equals</code> contract), unless the
340       * examined object itself is <code>null</code>, in which case the matcher will return a positive
341       * match.</p>
342       * 
343       * <p>The created matcher provides a special behaviour when examining <code>Array</code>s, whereby
344       * it will match if both the operand and the examined object are arrays of the same length and
345       * contain items that are equal to each other (according to the above rules) <b>in the same
346       * indexes</b>.</p> 
347       * <p/>
348       * For example:
349       * <pre>
350       * assertThat("foo", equalTo("foo"));
351       * assertThat(new String[] {"foo", "bar"}, equalTo(new String[] {"foo", "bar"}));
352       * </pre>
353       */
354      public static <T> org.hamcrest.Matcher<T> equalTo(T operand) {
355        return org.hamcrest.core.IsEqual.<T>equalTo(operand);
356      }
357    
358      /**
359       * Creates a matcher that matches when the examined object is an instance of the specified <code>type</code>,
360       * as determined by calling the {@link java.lang.Class#isInstance(Object)} method on that type, passing the
361       * the examined object.
362       * 
363       * <p>The created matcher forces a relationship between specified type and the examined object, and should be
364       * used when it is necessary to make generics conform, for example in the JMock clause
365       * <code>with(any(Thing.class))</code></p>
366       * <p/>
367       * For example: 
368       * <pre>assertThat(new Canoe(), instanceOf(Canoe.class));</pre>
369       */
370      public static <T> org.hamcrest.Matcher<T> any(java.lang.Class<T> type) {
371        return org.hamcrest.core.IsInstanceOf.<T>any(type);
372      }
373    
374      /**
375       * Creates a matcher that matches when the examined object is an instance of the specified <code>type</code>,
376       * as determined by calling the {@link java.lang.Class#isInstance(Object)} method on that type, passing the
377       * the examined object.
378       * 
379       * <p>The created matcher assumes no relationship between specified type and the examined object.</p>
380       * <p/>
381       * For example: 
382       * <pre>assertThat(new Canoe(), instanceOf(Paddlable.class));</pre>
383       */
384      public static <T> org.hamcrest.Matcher<T> instanceOf(java.lang.Class<?> type) {
385        return org.hamcrest.core.IsInstanceOf.<T>instanceOf(type);
386      }
387    
388      /**
389       * Creates a matcher that wraps an existing matcher, but inverts the logic by which
390       * it will match.
391       * <p/>
392       * For example:
393       * <pre>assertThat(cheese, is(not(equalTo(smelly))))</pre>
394       * 
395       * @param matcher
396       *     the matcher whose sense should be inverted
397       */
398      public static <T> org.hamcrest.Matcher<T> not(org.hamcrest.Matcher<T> matcher) {
399        return org.hamcrest.core.IsNot.<T>not(matcher);
400      }
401    
402      /**
403       * A shortcut to the frequently used <code>not(equalTo(x))</code>.
404       * <p/>
405       * For example:
406       * <pre>assertThat(cheese, is(not(smelly)))</pre>
407       * instead of:
408       * <pre>assertThat(cheese, is(not(equalTo(smelly))))</pre>
409       * 
410       * @param value
411       *     the value that any examined object should <b>not</b> equal
412       */
413      public static <T> org.hamcrest.Matcher<T> not(T value) {
414        return org.hamcrest.core.IsNot.<T>not(value);
415      }
416    
417      /**
418       * Creates a matcher that matches if examined object is <code>null</code>.
419       * <p/>
420       * For example:
421       * <pre>assertThat(cheese, is(nullValue())</pre>
422       */
423      public static org.hamcrest.Matcher<java.lang.Object> nullValue() {
424        return org.hamcrest.core.IsNull.nullValue();
425      }
426    
427      /**
428       * Creates a matcher that matches if examined object is <code>null</code>. Accepts a
429       * single dummy argument to facilitate type inference.
430       * <p/>
431       * For example:
432       * <pre>assertThat(cheese, is(nullValue(Cheese.class))</pre>
433       * 
434       * @param type
435       *     dummy parameter used to infer the generic type of the returned matcher
436       */
437      public static <T> org.hamcrest.Matcher<T> nullValue(java.lang.Class<T> type) {
438        return org.hamcrest.core.IsNull.<T>nullValue(type);
439      }
440    
441      /**
442       * A shortcut to the frequently used <code>not(nullValue())</code>.
443       * <p/>
444       * For example:
445       * <pre>assertThat(cheese, is(notNullValue()))</pre>
446       * instead of:
447       * <pre>assertThat(cheese, is(not(nullValue())))</pre>
448       */
449      public static org.hamcrest.Matcher<java.lang.Object> notNullValue() {
450        return org.hamcrest.core.IsNull.notNullValue();
451      }
452    
453      /**
454       * A shortcut to the frequently used <code>not(nullValue(X.class)). Accepts a
455       * single dummy argument to facilitate type inference.</code>.
456       * <p/>
457       * For example:
458       * <pre>assertThat(cheese, is(notNullValue(X.class)))</pre>
459       * instead of:
460       * <pre>assertThat(cheese, is(not(nullValue(X.class))))</pre>
461       * 
462       * @param type
463       *     dummy parameter used to infer the generic type of the returned matcher
464       */
465      public static <T> org.hamcrest.Matcher<T> notNullValue(java.lang.Class<T> type) {
466        return org.hamcrest.core.IsNull.<T>notNullValue(type);
467      }
468    
469      /**
470       * Creates a matcher that matches only when the examined object is the same instance as
471       * the specified target object.
472       * 
473       * @param target
474       *     the target instance against which others should be assessed
475       */
476      public static <T> org.hamcrest.Matcher<T> sameInstance(T target) {
477        return org.hamcrest.core.IsSame.<T>sameInstance(target);
478      }
479    
480      /**
481       * Creates a matcher that matches only when the examined object is the same instance as
482       * the specified target object.
483       * 
484       * @param target
485       *     the target instance against which others should be assessed
486       */
487      public static <T> org.hamcrest.Matcher<T> theInstance(T target) {
488        return org.hamcrest.core.IsSame.<T>theInstance(target);
489      }
490    
491      /**
492       * Creates a matcher that matches if the examined {@link String} contains the specified
493       * {@link String} anywhere.
494       * <p/>
495       * For example:
496       * <pre>assertThat("myStringOfNote", containsString("ring"))</pre>
497       * 
498       * @param substring
499       *     the substring that the returned matcher will expect to find within any examined string
500       */
501      public static org.hamcrest.Matcher<java.lang.String> containsString(java.lang.String substring) {
502        return org.hamcrest.core.StringContains.containsString(substring);
503      }
504    
505      /**
506       * Creates a matcher that matches if the examined {@link String} starts with the specified
507       * {@link String}.
508       * <p/>
509       * For example:
510       * <pre>assertThat("myStringOfNote", startsWith("my"))</pre>
511       * 
512       * @param prefix
513       *      the substring that the returned matcher will expect at the start of any examined string
514       */
515      public static org.hamcrest.Matcher<java.lang.String> startsWith(java.lang.String prefix) {
516        return org.hamcrest.core.StringStartsWith.startsWith(prefix);
517      }
518    
519      /**
520       * Creates a matcher that matches if the examined {@link String} ends with the specified
521       * {@link String}.
522       * <p/>
523       * For example:
524       * <pre>assertThat("myStringOfNote", endsWith("Note"))</pre>
525       * 
526       * @param suffix
527       *      the substring that the returned matcher will expect at the end of any examined string
528       */
529      public static org.hamcrest.Matcher<java.lang.String> endsWith(java.lang.String suffix) {
530        return org.hamcrest.core.StringEndsWith.endsWith(suffix);
531      }
532    
533    }