1 // Generated source. 2 package org.hamcrest; 3 4 public class CoreMatchers { 5 6 /** 7 * Decorates another Matcher, retaining the behavior but allowing tests 8 * to be slightly more expressive. 9 * 10 * eg. assertThat(cheese, equalTo(smelly)) 11 * vs assertThat(cheese, is(equalTo(smelly))) 12 */ is(org.hamcrest.Matcher<T> matcher)13 public static <T> org.hamcrest.Matcher<T> is(org.hamcrest.Matcher<T> matcher) { 14 return org.hamcrest.core.Is.is(matcher); 15 } 16 17 /** 18 * This is a shortcut to the frequently used is(equalTo(x)). 19 * 20 * eg. assertThat(cheese, is(equalTo(smelly))) 21 * vs assertThat(cheese, is(smelly)) 22 */ is(T value)23 public static <T> org.hamcrest.Matcher<T> is(T value) { 24 return org.hamcrest.core.Is.is(value); 25 } 26 27 /** 28 * This is a shortcut to the frequently used is(instanceOf(SomeClass.class)). 29 * 30 * eg. assertThat(cheese, is(instanceOf(Cheddar.class))) 31 * vs assertThat(cheese, is(Cheddar.class)) 32 */ is(java.lang.Class<?> type)33 public static org.hamcrest.Matcher<java.lang.Object> is(java.lang.Class<?> type) { 34 return org.hamcrest.core.Is.is(type); 35 } 36 37 /** 38 * Inverts the rule. 39 */ not(org.hamcrest.Matcher<T> matcher)40 public static <T> org.hamcrest.Matcher<T> not(org.hamcrest.Matcher<T> matcher) { 41 return org.hamcrest.core.IsNot.not(matcher); 42 } 43 44 /** 45 * This is a shortcut to the frequently used not(equalTo(x)). 46 * 47 * eg. assertThat(cheese, is(not(equalTo(smelly)))) 48 * vs assertThat(cheese, is(not(smelly))) 49 */ not(T value)50 public static <T> org.hamcrest.Matcher<T> not(T value) { 51 return org.hamcrest.core.IsNot.not(value); 52 } 53 54 /** 55 * Is the value equal to another value, as tested by the 56 * {@link java.lang.Object#equals} invokedMethod? 57 */ equalTo(T operand)58 public static <T> org.hamcrest.Matcher<T> equalTo(T operand) { 59 return org.hamcrest.core.IsEqual.equalTo(operand); 60 } 61 62 /** 63 * Is the value an instance of a particular type? 64 */ instanceOf(java.lang.Class<?> type)65 public static org.hamcrest.Matcher<java.lang.Object> instanceOf(java.lang.Class<?> type) { 66 return org.hamcrest.core.IsInstanceOf.instanceOf(type); 67 } 68 69 /** 70 * Evaluates to true only if ALL of the passed in matchers evaluate to true. 71 */ allOf(org.hamcrest.Matcher<? extends T>.... matchers)72 public static <T> org.hamcrest.Matcher<T> allOf(org.hamcrest.Matcher<? extends T>... matchers) { 73 return org.hamcrest.core.AllOf.allOf(matchers); 74 } 75 76 /** 77 * Evaluates to true only if ALL of the passed in matchers evaluate to true. 78 */ allOf(java.lang.Iterable<org.hamcrest.Matcher<? extends T>> matchers)79 public static <T> org.hamcrest.Matcher<T> allOf(java.lang.Iterable<org.hamcrest.Matcher<? extends T>> matchers) { 80 return org.hamcrest.core.AllOf.allOf(matchers); 81 } 82 83 /** 84 * Evaluates to true if ANY of the passed in matchers evaluate to true. 85 */ anyOf(org.hamcrest.Matcher<? extends T>.... matchers)86 public static <T> org.hamcrest.Matcher<T> anyOf(org.hamcrest.Matcher<? extends T>... matchers) { 87 return org.hamcrest.core.AnyOf.anyOf(matchers); 88 } 89 90 /** 91 * Evaluates to true if ANY of the passed in matchers evaluate to true. 92 */ anyOf(java.lang.Iterable<org.hamcrest.Matcher<? extends T>> matchers)93 public static <T> org.hamcrest.Matcher<T> anyOf(java.lang.Iterable<org.hamcrest.Matcher<? extends T>> matchers) { 94 return org.hamcrest.core.AnyOf.anyOf(matchers); 95 } 96 97 /** 98 * Creates a new instance of IsSame 99 * 100 * @param object The predicate evaluates to true only when the argument is 101 * this object. 102 */ sameInstance(T object)103 public static <T> org.hamcrest.Matcher<T> sameInstance(T object) { 104 return org.hamcrest.core.IsSame.sameInstance(object); 105 } 106 107 /** 108 * This matcher always evaluates to true. 109 */ anything()110 public static <T> org.hamcrest.Matcher<T> anything() { 111 return org.hamcrest.core.IsAnything.anything(); 112 } 113 114 /** 115 * This matcher always evaluates to true. 116 * 117 * @param description A meaningful string used when describing itself. 118 */ anything(java.lang.String description)119 public static <T> org.hamcrest.Matcher<T> anything(java.lang.String description) { 120 return org.hamcrest.core.IsAnything.anything(description); 121 } 122 123 /** 124 * This matcher always evaluates to true. With type inference. 125 */ any(java.lang.Class<T> type)126 public static <T> org.hamcrest.Matcher<T> any(java.lang.Class<T> type) { 127 return org.hamcrest.core.IsAnything.any(type); 128 } 129 130 /** 131 * Matches if value is null. 132 */ nullValue()133 public static <T> org.hamcrest.Matcher<T> nullValue() { 134 return org.hamcrest.core.IsNull.nullValue(); 135 } 136 137 /** 138 * Matches if value is null. With type inference. 139 */ nullValue(java.lang.Class<T> type)140 public static <T> org.hamcrest.Matcher<T> nullValue(java.lang.Class<T> type) { 141 return org.hamcrest.core.IsNull.nullValue(type); 142 } 143 144 /** 145 * Matches if value is not null. 146 */ notNullValue()147 public static <T> org.hamcrest.Matcher<T> notNullValue() { 148 return org.hamcrest.core.IsNull.notNullValue(); 149 } 150 151 /** 152 * Matches if value is not null. With type inference. 153 */ notNullValue(java.lang.Class<T> type)154 public static <T> org.hamcrest.Matcher<T> notNullValue(java.lang.Class<T> type) { 155 return org.hamcrest.core.IsNull.notNullValue(type); 156 } 157 158 /** 159 * Wraps an existing matcher and overrides the description when it fails. 160 */ describedAs(java.lang.String description, org.hamcrest.Matcher<T> matcher, java.lang.Object... values)161 public static <T> org.hamcrest.Matcher<T> describedAs(java.lang.String description, org.hamcrest.Matcher<T> matcher, java.lang.Object... values) { 162 return org.hamcrest.core.DescribedAs.describedAs(description, matcher, values); 163 } 164 165 } 166