File tree Expand file tree Collapse file tree
src/library/org/hamcrest/core Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33 <!-- Core -->
44 <factory class =" org.hamcrest.core.Is" />
5- <factory class =" org.hamcrest.core.AllOf" />
6- <factory class =" org.hamcrest.core.AnyOf" />
75 <factory class =" org.hamcrest.core.IsNot" />
86 <factory class =" org.hamcrest.core.IsEqual" />
7+ <factory class =" org.hamcrest.core.IsInstanceOf" />
8+ <factory class =" org.hamcrest.core.AllOf" />
9+ <factory class =" org.hamcrest.core.AnyOf" />
910 <factory class =" org.hamcrest.core.IsSame" />
1011 <factory class =" org.hamcrest.core.IsAnything" />
1112 <factory class =" org.hamcrest.core.IsNull" />
12- <factory class =" org.hamcrest.core.IsInstanceOf" />
1313 <factory class =" org.hamcrest.core.DescribedAs" />
1414
1515 <!-- Collection -->
Original file line number Diff line number Diff line change 11package org .hamcrest .core ;
22
3+ import static org .hamcrest .core .IsInstanceOf .instanceOf ;
34import static org .hamcrest .core .IsEqual .equalTo ;
45import org .hamcrest .Factory ;
56import org .hamcrest .Matcher ;
@@ -53,5 +54,16 @@ public static <T> Matcher<T> is(T value) {
5354 return is (equalTo (value ));
5455 }
5556
57+ /**
58+ * This is a shortcut to the frequently used is(instanceOf(SomeClass.class)).
59+ *
60+ * eg. assertThat(cheese, is(instanceOf(Cheddar.class)))
61+ * vs assertThat(cheese, is(Cheddar.class))
62+ */
63+ @ Factory
64+ public static <T > Matcher <T > is (Class <T > type ) {
65+ return is (instanceOf (type ));
66+ }
67+
5668}
5769
You can’t perform that action at this time.
0 commit comments