Uses of Interface
org.hamcrest.Matcher
-
Packages that use Matcher Package Description org.hamcrest org.hamcrest.beans Matchers of Java Bean properties and their values.org.hamcrest.collection Matchers of arrays and collections.org.hamcrest.comparator org.hamcrest.core Fundamental matchers of objects and values, and composite matchers.org.hamcrest.internal org.hamcrest.io org.hamcrest.number Matchers that perform numeric comparisons.org.hamcrest.object Matchers that inspect objects and classes.org.hamcrest.text Matchers that perform text comparisons.org.hamcrest.xml Matchers of XML documents. -
-
Uses of Matcher in org.hamcrest
Classes in org.hamcrest that implement Matcher Modifier and Type Class Description classBaseMatcher<T>BaseClass for all Matcher implementations.classCustomMatcher<T>Utility class for writing one off matchers.classCustomTypeSafeMatcher<T>Utility class for writing one off matchers.classDiagnosingMatcher<T>TODO(ngd): Document.classFeatureMatcher<T,U>Supporting class for matching a feature of an object.classTypeSafeDiagnosingMatcher<T>Convenient base class for Matchers that require a non-null value of a specific type and that will report why the received value has been rejected.classTypeSafeMatcher<T>Convenient base class for Matchers that require a non-null value of a specific type.Methods in org.hamcrest that return Matcher Modifier and Type Method Description static <T> Matcher<T>CoreMatchers. allOf(java.lang.Iterable<Matcher<? super T>> matchers)Creates a matcher that matches if the examined object matches ALL of the specified matchers.static <T> Matcher<T>CoreMatchers. allOf(Matcher<? super T>... matchers)Creates a matcher that matches if the examined object matches ALL of the specified matchers.static <T> Matcher<T>Matchers. allOf(java.lang.Iterable<Matcher<? super T>> matchers)Creates a matcher that matches if the examined object matches ALL of the specified matchers.static <T> Matcher<T>Matchers. allOf(Matcher<? super T>... matchers)Creates a matcher that matches if the examined object matches ALL of the specified matchers.static <T> Matcher<T>Matchers. allOf(Matcher<? super T> first, Matcher<? super T> second)Creates a matcher that matches if the examined object matches ALL of the specified matchers.static <T> Matcher<T>Matchers. allOf(Matcher<? super T> first, Matcher<? super T> second, Matcher<? super T> third)Creates a matcher that matches if the examined object matches ALL of the specified matchers.static <T> Matcher<T>Matchers. allOf(Matcher<? super T> first, Matcher<? super T> second, Matcher<? super T> third, Matcher<? super T> fourth)Creates a matcher that matches if the examined object matches ALL of the specified matchers.static <T> Matcher<T>Matchers. allOf(Matcher<? super T> first, Matcher<? super T> second, Matcher<? super T> third, Matcher<? super T> fourth, Matcher<? super T> fifth)Creates a matcher that matches if the examined object matches ALL of the specified matchers.static <T> Matcher<T>Matchers. allOf(Matcher<? super T> first, Matcher<? super T> second, Matcher<? super T> third, Matcher<? super T> fourth, Matcher<? super T> fifth, Matcher<? super T> sixth)Creates a matcher that matches if the examined object matches ALL of the specified matchers.static <K,V>
Matcher<java.util.Map<? extends K,? extends V>>Matchers. aMapWithSize(int size)Creates a matcher forMaps that matches when thesize()method returns a value equal to the specifiedsize.static <K,V>
Matcher<java.util.Map<? extends K,? extends V>>Matchers. aMapWithSize(Matcher<? super java.lang.Integer> sizeMatcher)Creates a matcher forMaps that matches when thesize()method returns a value that satisfies the specified matcher.static <K,V>
Matcher<java.util.Map<? extends K,? extends V>>Matchers. anEmptyMap()Creates a matcher forMaps that matches when thesize()method returns zero.static <T> Matcher<T>CoreMatchers. any(java.lang.Class<T> type)Creates a matcher that matches when the examined object is an instance of the specifiedtype, as determined by calling theClass.isInstance(Object)method on that type, passing the the examined object.static <T> Matcher<T>Matchers. any(java.lang.Class<T> type)Creates a matcher that matches when the examined object is an instance of the specifiedtype, as determined by calling theClass.isInstance(Object)method on that type, passing the the examined object.static Matcher<java.lang.Object>CoreMatchers. anything()Creates a matcher that always matches, regardless of the examined object.static Matcher<java.lang.Object>CoreMatchers. anything(java.lang.String description)Creates a matcher that always matches, regardless of the examined object, but describes itself with the specifiedString.static Matcher<java.lang.Object>Matchers. anything()Creates a matcher that always matches, regardless of the examined object.static Matcher<java.lang.Object>Matchers. anything(java.lang.String description)Creates a matcher that always matches, regardless of the examined object, but describes itself with the specifiedString.static <E> Matcher<E[]>Matchers. arrayContaining(E... items)Creates a matcher for arrays that matches when each item in the examined array is logically equal to the corresponding item in the specified items.static <E> Matcher<E[]>Matchers. arrayContaining(java.util.List<Matcher<? super E>> itemMatchers)Creates a matcher for arrays that matches when each item in the examined array satisfies the corresponding matcher in the specified list of matchers.static <E> Matcher<E[]>Matchers. arrayContaining(Matcher<? super E>... itemMatchers)Creates a matcher for arrays that matches when each item in the examined array satisfies the corresponding matcher in the specified matchers.static <E> Matcher<E[]>Matchers. arrayContainingInAnyOrder(E... items)Creates an order agnostic matcher for arrays that matches when each item in the examined array is logically equal to one item anywhere in the specified items.static <E> Matcher<E[]>Matchers. arrayContainingInAnyOrder(java.util.Collection<Matcher<? super E>> itemMatchers)Creates an order agnostic matcher for arrays that matches when each item in the examined array satisfies one matcher anywhere in the specified collection of matchers.static <E> Matcher<E[]>Matchers. arrayContainingInAnyOrder(Matcher<? super E>... itemMatchers)Creates an order agnostic matcher for arrays that matches when each item in the examined array satisfies one matcher anywhere in the specified matchers.static <E> Matcher<E[]>Matchers. arrayWithSize(int size)Creates a matcher for arrays that matches when thelengthof the array equals the specifiedsize.static <E> Matcher<E[]>Matchers. arrayWithSize(Matcher<? super java.lang.Integer> sizeMatcher)Creates a matcher for arrays that matches when thelengthof the array satisfies the specified matcher.static Matcher<java.lang.String>Matchers. blankOrNullString()Creates a matcher ofStringthat matches when the examined string isnull, or contains zero or more whitespace characters and nothing else.static Matcher<java.lang.String>Matchers. blankString()Creates a matcher ofStringthat matches when the examined string contains zero or more whitespace characters and nothing else.static Matcher<java.lang.Double>Matchers. closeTo(double operand, double error)Creates a matcher ofDoubles that matches when an examined double is equal to the specifiedoperand, within a range of +/-error.static Matcher<java.math.BigDecimal>Matchers. closeTo(java.math.BigDecimal operand, java.math.BigDecimal error)Creates a matcher ofBigDecimals that matches when an examined BigDecimal is equal to the specifiedoperand, within a range of +/-error.static <T extends java.lang.Comparable<T>>
Matcher<T>Matchers. comparesEqualTo(T value)Creates a matcher ofComparableobject that matches when the examined object is equal to the specified value, as reported by thecompareTomethod of the examined object.static <E> Matcher<java.lang.Iterable<? extends E>>Matchers. contains(E... items)Creates a matcher forIterables that matches when a single pass over the examinedIterableyields a series of items, each logically equal to the corresponding item in the specified items.static <E> Matcher<java.lang.Iterable<? extends E>>Matchers. contains(java.util.List<Matcher<? super E>> itemMatchers)Creates a matcher forIterables that matches when a single pass over the examinedIterableyields a series of items, each satisfying the corresponding matcher in the specified list of matchers.static <E> Matcher<java.lang.Iterable<? extends E>>Matchers. contains(Matcher<? super E> itemMatcher)Creates a matcher forIterables that matches when a single pass over the examinedIterableyields a single item that satisfies the specified matcher.static <E> Matcher<java.lang.Iterable<? extends E>>Matchers. contains(Matcher<? super E>... itemMatchers)Creates a matcher forIterables that matches when a single pass over the examinedIterableyields a series of items, each satisfying the corresponding matcher in the specified matchers.static <T> Matcher<java.lang.Iterable<? extends T>>Matchers. containsInAnyOrder(java.util.Collection<Matcher<? super T>> itemMatchers)Creates an order agnostic matcher forIterables that matches when a single pass over the examinedIterableyields a series of items, each satisfying one matcher anywhere in the specified collection of matchers.static <T> Matcher<java.lang.Iterable<? extends T>>Matchers. containsInAnyOrder(Matcher<? super T>... itemMatchers)Creates an order agnostic matcher forIterables that matches when a single pass over the examinedIterableyields a series of items, each satisfying one matcher anywhere in the specified matchers.static <T> Matcher<java.lang.Iterable<? extends T>>Matchers. containsInAnyOrder(T... items)Creates an order agnostic matcher forIterables that matches when a single pass over the examinedIterableyields a series of items, each logically equal to one item anywhere in the specified items.static <E> Matcher<java.lang.Iterable<? extends E>>Matchers. containsInRelativeOrder(E... items)Creates a matcher forIterables that matches when a single pass over the examinedIterableyields a series of items, that contains items logically equal to the corresponding item in the specified items, in the same relative order For example:static <E> Matcher<java.lang.Iterable<? extends E>>Matchers. containsInRelativeOrder(java.util.List<Matcher<? super E>> itemMatchers)Creates a matcher forIterables that matches when a single pass over the examinedIterableyields a series of items, that contains items satisfying the corresponding matcher in the specified list of matchers, in the same relative order.static <E> Matcher<java.lang.Iterable<? extends E>>Matchers. containsInRelativeOrder(Matcher<? super E>... itemMatchers)Creates a matcher forIterables that matches when a single pass over the examinedIterableyields a series of items, that each satisfying the corresponding matcher in the specified matchers, in the same relative order.static Matcher<java.lang.String>CoreMatchers. containsString(java.lang.String substring)Creates a matcher that matches if the examinedStringcontains the specifiedStringanywhere.static Matcher<java.lang.String>Matchers. containsString(java.lang.String substring)Creates a matcher that matches if the examinedStringcontains the specifiedStringanywhere.static Matcher<java.lang.String>CoreMatchers. containsStringIgnoringCase(java.lang.String substring)Creates a matcher that matches if the examinedStringcontains the specifiedStringanywhere, ignoring case.static Matcher<java.lang.String>Matchers. containsStringIgnoringCase(java.lang.String substring)Creates a matcher that matches if the examinedStringcontains the specifiedStringanywhere, ignoring case.static <T> Matcher<T>CoreMatchers. describedAs(java.lang.String description, Matcher<T> matcher, java.lang.Object... values)Wraps an existing matcher, overriding its description with that specified.static <T> Matcher<T>Matchers. describedAs(java.lang.String description, Matcher<T> matcher, java.lang.Object... values)Wraps an existing matcher, overriding its description with that specified.static <E> Matcher<java.util.Collection<? extends E>>Matchers. empty()Creates a matcher forCollections matching examined collections whoseisEmptymethod returnstrue.static <E> Matcher<E[]>Matchers. emptyArray()Creates a matcher for arrays that matches when thelengthof the array is zero.static <E> Matcher<java.util.Collection<E>>Matchers. emptyCollectionOf(java.lang.Class<E> unusedToForceReturnType)Creates a matcher forCollections matching examined collections whoseisEmptymethod returnstrue.static <E> Matcher<java.lang.Iterable<? extends E>>Matchers. emptyIterable()Creates a matcher forIterables matching examined iterables that yield no items.static <E> Matcher<java.lang.Iterable<E>>Matchers. emptyIterableOf(java.lang.Class<E> unusedToForceReturnType)Creates a matcher forIterables matching examined iterables that yield no items.static Matcher<java.lang.String>Matchers. emptyOrNullString()Creates a matcher ofStringthat matches when the examined string isnull, or has zero length.static Matcher<java.lang.String>Matchers. emptyString()Creates a matcher ofStringthat matches when the examined string has zero length.static Matcher<java.lang.String>CoreMatchers. endsWith(java.lang.String suffix)Creates a matcher that matches if the examinedStringends with the specifiedString.static Matcher<java.lang.String>Matchers. endsWith(java.lang.String suffix)Creates a matcher that matches if the examinedStringends with the specifiedString.static Matcher<java.lang.String>CoreMatchers. endsWithIgnoringCase(java.lang.String suffix)Creates a matcher that matches if the examinedStringends with the specifiedString, ignoring case.static Matcher<java.lang.String>Matchers. endsWithIgnoringCase(java.lang.String suffix)Creates a matcher that matches if the examinedStringends with the specifiedString, ignoring case.static <T> Matcher<T>CoreMatchers. equalTo(T operand)Creates a matcher that matches when the examined object is logically equal to the specifiedoperand, as determined by calling theObject.equals(java.lang.Object)method on the examined object.static <T> Matcher<T>Matchers. equalTo(T operand)Creates a matcher that matches when the examined object is logically equal to the specifiedoperand, as determined by calling theObject.equals(java.lang.Object)method on the examined object.static Matcher<java.lang.String>Matchers. equalToCompressingWhiteSpace(java.lang.String expectedString)Creates a matcher ofStringthat matches when the examined string is equal to the specified expectedString, when whitespace differences are (mostly) ignored.static Matcher<java.lang.String>Matchers. equalToIgnoringCase(java.lang.String expectedString)Creates a matcher ofStringthat matches when the examined string is equal to the specified expectedString, ignoring case.static Matcher<java.lang.String>Matchers. equalToIgnoringWhiteSpace(java.lang.String expectedString)Deprecated.static Matcher<java.lang.Object>CoreMatchers. equalToObject(java.lang.Object operand)Creates anIsEqualmatcher that does not enforce the values being compared to be of the same static type.static Matcher<java.lang.Object>Matchers. equalToObject(java.lang.Object operand)Creates anIsEqualmatcher that does not enforce the values being compared to be of the same static type.static Matcher<java.util.EventObject>Matchers. eventFrom(java.lang.Class<? extends java.util.EventObject> eventClass, java.lang.Object source)Creates a matcher ofEventObjectthat matches any object derived from eventClass announced by source.static Matcher<java.util.EventObject>Matchers. eventFrom(java.lang.Object source)Creates a matcher ofEventObjectthat matches any EventObject announced by source.static <U> Matcher<java.lang.Iterable<? extends U>>CoreMatchers. everyItem(Matcher<U> itemMatcher)Creates a matcher forIterables that only matches when a single pass over the examinedIterableyields items that are all matched by the specifieditemMatcher.static <U> Matcher<java.lang.Iterable<? extends U>>Matchers. everyItem(Matcher<U> itemMatcher)Creates a matcher forIterables that only matches when a single pass over the examinedIterableyields items that are all matched by the specifieditemMatcher.static <T extends java.lang.Comparable<T>>
Matcher<T>Matchers. greaterThan(T value)Creates a matcher ofComparableobject that matches when the examined object is greater than the specified value, as reported by thecompareTomethod of the examined object.static <T extends java.lang.Comparable<T>>
Matcher<T>Matchers. greaterThanOrEqualTo(T value)Creates a matcher ofComparableobject that matches when the examined object is greater than or equal to the specified value, as reported by thecompareTomethod of the examined object.static <K,V>
Matcher<java.util.Map<? extends K,? extends V>>Matchers. hasEntry(K key, V value)Creates a matcher forMaps matching when the examinedMapcontains at least one entry whose key equals the specifiedkeyand whose value equals the specifiedvalue.static <K,V>
Matcher<java.util.Map<? extends K,? extends V>>Matchers. hasEntry(Matcher<? super K> keyMatcher, Matcher<? super V> valueMatcher)Creates a matcher forMaps matching when the examinedMapcontains at least one entry whose key satisfies the specifiedkeyMatcherand whose value satisfies the specifiedvalueMatcher.static <T> Matcher<java.lang.Iterable<? super T>>CoreMatchers. hasItem(Matcher<? super T> itemMatcher)Creates a matcher forIterables that only matches when a single pass over the examinedIterableyields at least one item that is matched by the specifieditemMatcher.static <T> Matcher<java.lang.Iterable<? super T>>CoreMatchers. hasItem(T item)Creates a matcher forIterables that only matches when a single pass over the examinedIterableyields at least one item that is equal to the specifieditem.static <T> Matcher<java.lang.Iterable<? super T>>Matchers. hasItem(Matcher<? super T> itemMatcher)Creates a matcher forIterables that only matches when a single pass over the examinedIterableyields at least one item that is matched by the specifieditemMatcher.static <T> Matcher<java.lang.Iterable<? super T>>Matchers. hasItem(T item)Creates a matcher forIterables that only matches when a single pass over the examinedIterableyields at least one item that is equal to the specifieditem.static <T> Matcher<T[]>Matchers. hasItemInArray(Matcher<? super T> elementMatcher)Creates a matcher for arrays that matches when the examined array contains at least one item that is matched by the specifiedelementMatcher.static <T> Matcher<T[]>Matchers. hasItemInArray(T element)A shortcut to the frequently usedhasItemInArray(equalTo(x)).static <T> Matcher<java.lang.Iterable<T>>CoreMatchers. hasItems(Matcher<? super T>... itemMatchers)Creates a matcher forIterables that matches when consecutive passes over the examinedIterableyield at least one item that is matched by the corresponding matcher from the specifieditemMatchers.static <T> Matcher<java.lang.Iterable<T>>CoreMatchers. hasItems(T... items)Creates a matcher forIterables that matches when consecutive passes over the examinedIterableyield at least one item that is equal to the corresponding item from the specifieditems.static <T> Matcher<java.lang.Iterable<T>>Matchers. hasItems(Matcher<? super T>... itemMatchers)Creates a matcher forIterables that matches when consecutive passes over the examinedIterableyield at least one item that is matched by the corresponding matcher from the specifieditemMatchers.static <T> Matcher<java.lang.Iterable<T>>Matchers. hasItems(T... items)Creates a matcher forIterables that matches when consecutive passes over the examinedIterableyield at least one item that is equal to the corresponding item from the specifieditems.static <K> Matcher<java.util.Map<? extends K,?>>Matchers. hasKey(K key)Creates a matcher forMaps matching when the examinedMapcontains at least one key that is equal to the specified key.static <K> Matcher<java.util.Map<? extends K,?>>Matchers. hasKey(Matcher<? super K> keyMatcher)Creates a matcher forMaps matching when the examinedMapcontains at least one key that satisfies the specified matcher.static Matcher<java.lang.CharSequence>Matchers. hasLength(int length)Creates a matcher ofCharSequencethat matches when a char sequence has the length of the specifiedargument.static Matcher<java.lang.CharSequence>Matchers. hasLength(Matcher<? super java.lang.Integer> lengthMatcher)Creates a matcher ofCharSequencethat matches when a char sequence has the length that satisfies the specified matcher.static <T> Matcher<T>Matchers. hasProperty(java.lang.String propertyName)Creates a matcher that matches when the examined object has a JavaBean property with the specified name.static <T> Matcher<T>Matchers. hasProperty(java.lang.String propertyName, Matcher<?> valueMatcher)Creates a matcher that matches when the examined object has a JavaBean property with the specified name whose value satisfies the specified matcher.static <E> Matcher<java.util.Collection<? extends E>>Matchers. hasSize(int size)Creates a matcher forCollections that matches when thesize()method returns a value equal to the specifiedsize.static <E> Matcher<java.util.Collection<? extends E>>Matchers. hasSize(Matcher<? super java.lang.Integer> sizeMatcher)Creates a matcher forCollections that matches when thesize()method returns a value that satisfies the specified matcher.static <T> Matcher<T>Matchers. hasToString(java.lang.String expectedToString)Creates a matcher that matches any examined object whosetoStringmethod returns a value equalTo the specified string.static <T> Matcher<T>Matchers. hasToString(Matcher<? super java.lang.String> toStringMatcher)Creates a matcher that matches any examined object whosetoStringmethod returns a value that satisfies the specified matcher.static <V> Matcher<java.util.Map<?,? extends V>>Matchers. hasValue(Matcher<? super V> valueMatcher)Creates a matcher forMaps matching when the examinedMapcontains at least one value that satisfies the specified valueMatcher.static <V> Matcher<java.util.Map<?,? extends V>>Matchers. hasValue(V value)Creates a matcher forMaps matching when the examinedMapcontains at least one value that is equal to the specified value.static Matcher<org.w3c.dom.Node>Matchers. hasXPath(java.lang.String xPath)Creates a matcher ofNodes that matches when the examined node contains a node at the specifiedxPath, with any content.static Matcher<org.w3c.dom.Node>Matchers. hasXPath(java.lang.String xPath, javax.xml.namespace.NamespaceContext namespaceContext)Creates a matcher ofNodes that matches when the examined node contains a node at the specifiedxPathwithin the specified namespace context, with any content.static Matcher<org.w3c.dom.Node>Matchers. hasXPath(java.lang.String xPath, javax.xml.namespace.NamespaceContext namespaceContext, Matcher<java.lang.String> valueMatcher)Creates a matcher ofNodes that matches when the examined node has a value at the specifiedxPath, within the specifiednamespaceContext, that satisfies the specifiedvalueMatcher.static Matcher<org.w3c.dom.Node>Matchers. hasXPath(java.lang.String xPath, Matcher<java.lang.String> valueMatcher)Creates a matcher ofNodes that matches when the examined node has a value at the specifiedxPaththat satisfies the specifiedvalueMatcher.static <T> Matcher<T>Matchers. in(java.util.Collection<T> collection)Creates a matcher that matches when the examined object is found within the specified collection.static <T> Matcher<T>Matchers. in(T[] elements)Creates a matcher that matches when the examined object is found within the specified array.static <T> Matcher<T>CoreMatchers. instanceOf(java.lang.Class<?> type)Creates a matcher that matches when the examined object is an instance of the specifiedtype, as determined by calling theClass.isInstance(Object)method on that type, passing the the examined object.static <T> Matcher<T>Matchers. instanceOf(java.lang.Class<?> type)Creates a matcher that matches when the examined object is an instance of the specifiedtype, as determined by calling theClass.isInstance(Object)method on that type, passing the the examined object.static <T> Matcher<T>CoreMatchers. is(Matcher<T> matcher)Decorates another Matcher, retaining its behaviour, but allowing tests to be slightly more expressive.static <T> Matcher<T>CoreMatchers. is(T value)A shortcut to the frequently usedis(equalTo(x)).static <T> Matcher<T>Matchers. is(Matcher<T> matcher)Decorates another Matcher, retaining its behaviour, but allowing tests to be slightly more expressive.static <T> Matcher<T>Matchers. is(T value)A shortcut to the frequently usedis(equalTo(x)).static <T> Matcher<T>CoreMatchers. isA(java.lang.Class<T> type)A shortcut to the frequently usedis(instanceOf(SomeClass.class)).static <T> Matcher<T>Matchers. isA(java.lang.Class<?> type)A shortcut to the frequently usedis(instanceOf(SomeClass.class)).static Matcher<java.lang.String>Matchers. isEmptyOrNullString()Deprecated.use is(emptyOrNullString()) insteadstatic Matcher<java.lang.String>Matchers. isEmptyString()Deprecated.use is(emptyString()) insteadstatic <T> Matcher<T>Matchers. isIn(java.util.Collection<T> collection)Deprecated.use is(in(...)) insteadstatic <T> Matcher<T>Matchers. isIn(T[] elements)Deprecated.use is(in(...)) insteadstatic <T> Matcher<T>Matchers. isOneOf(T... elements)Deprecated.use is(oneOf(...)) insteadstatic <E> Matcher<java.lang.Iterable<E>>Matchers. iterableWithSize(int size)Creates a matcher forIterables that matches when a single pass over the examinedIterableyields an item count that is equal to the specifiedsizeargument.static <E> Matcher<java.lang.Iterable<E>>Matchers. iterableWithSize(Matcher<? super java.lang.Integer> sizeMatcher)Creates a matcher forIterables that matches when a single pass over the examinedIterableyields an item count that satisfies the specified matcher.static <T extends java.lang.Comparable<T>>
Matcher<T>Matchers. lessThan(T value)Creates a matcher ofComparableobject that matches when the examined object is less than the specified value, as reported by thecompareTomethod of the examined object.static <T extends java.lang.Comparable<T>>
Matcher<T>Matchers. lessThanOrEqualTo(T value)Creates a matcher ofComparableobject that matches when the examined object is less than or equal to the specified value, as reported by thecompareTomethod of the examined object.static Matcher<java.lang.String>Matchers. matchesPattern(java.lang.String regex)Creates a matcher ofStringthat matches when the examined string exactly matches the given regular expression, treated as aPattern.static Matcher<java.lang.String>Matchers. matchesPattern(java.util.regex.Pattern pattern)Creates a matcher ofStringthat matches when the examined string exactly matches the givenPattern.static Matcher<java.lang.String>Matchers. matchesRegex(java.lang.String regex)Validate a string with a regex.static Matcher<java.lang.String>Matchers. matchesRegex(java.util.regex.Pattern pattern)Validate a string with aPattern.static <T> Matcher<T>CoreMatchers. not(Matcher<T> matcher)Creates a matcher that wraps an existing matcher, but inverts the logic by which it will match.static <T> Matcher<T>CoreMatchers. not(T value)A shortcut to the frequently usednot(equalTo(x)).static <T> Matcher<T>Matchers. not(Matcher<T> matcher)Creates a matcher that wraps an existing matcher, but inverts the logic by which it will match.static <T> Matcher<T>Matchers. not(T value)A shortcut to the frequently usednot(equalTo(x)).static Matcher<java.lang.Double>Matchers. notANumber()Creates a matcher ofDoubles that matches when an examined double is not a number.static Matcher<java.lang.Object>CoreMatchers. notNullValue()A shortcut to the frequently usednot(nullValue()).static <T> Matcher<T>CoreMatchers. notNullValue(java.lang.Class<T> type)A shortcut to the frequently usednot(nullValue(X.class)).static Matcher<java.lang.Object>Matchers. notNullValue()A shortcut to the frequently usednot(nullValue()).static <T> Matcher<T>Matchers. notNullValue(java.lang.Class<T> type)A shortcut to the frequently usednot(nullValue(X.class)).static Matcher<java.lang.Object>CoreMatchers. nullValue()Creates a matcher that matches if examined object isnull.static <T> Matcher<T>CoreMatchers. nullValue(java.lang.Class<T> type)Creates a matcher that matches if examined object isnull.static Matcher<java.lang.Object>Matchers. nullValue()Creates a matcher that matches if examined object isnull.static <T> Matcher<T>Matchers. nullValue(java.lang.Class<T> type)Creates a matcher that matches if examined object isnull.static <T> Matcher<T>Matchers. oneOf(T... elements)Creates a matcher that matches when the examined object is equal to one of the specified elements.static <T> Matcher<T>CoreMatchers. sameInstance(T target)Creates a matcher that matches only when the examined object is the same instance as the specified target object.static <T> Matcher<T>Matchers. sameInstance(T target)Creates a matcher that matches only when the examined object is the same instance as the specified target object.static <B> Matcher<B>Matchers. samePropertyValuesAs(B expectedBean, java.lang.String... ignoredProperties)Creates a matcher that matches when the examined object has values for all of its JavaBean properties that are equal to the corresponding values of the specified bean.static Matcher<java.lang.String>CoreMatchers. startsWith(java.lang.String prefix)Creates a matcher that matches if the examinedStringstarts with the specifiedString.static Matcher<java.lang.String>Matchers. startsWith(java.lang.String prefix)Creates a matcher that matches if the examinedStringstarts with the specifiedString.static Matcher<java.lang.String>CoreMatchers. startsWithIgnoringCase(java.lang.String prefix)Creates a matcher that matches if the examinedStringstarts with the specifiedString, ignoring casestatic Matcher<java.lang.String>Matchers. startsWithIgnoringCase(java.lang.String prefix)Creates a matcher that matches if the examinedStringstarts with the specifiedString, ignoring casestatic Matcher<java.lang.String>Matchers. stringContainsInOrder(java.lang.Iterable<java.lang.String> substrings)Creates a matcher ofStringthat matches when the examined string contains all of the specified substrings, considering the order of their appearance.static Matcher<java.lang.String>Matchers. stringContainsInOrder(java.lang.String... substrings)Creates a matcher ofStringthat matches when the examined string contains all of the specified substrings, considering the order of their appearance.static <T> Matcher<T>CoreMatchers. theInstance(T target)Creates a matcher that matches only when the examined object is the same instance as the specified target object.static <T> Matcher<T>Matchers. theInstance(T target)Creates a matcher that matches only when the examined object is the same instance as the specified target object.static <T> Matcher<java.lang.Class<?>>Matchers. typeCompatibleWith(java.lang.Class<T> baseType)Creates a matcher ofClassthat matches when the specified baseType is assignable from the examined class.Methods in org.hamcrest with parameters of type Matcher Modifier and Type Method Description static <T> Matcher<T>CoreMatchers. allOf(Matcher<? super T>... matchers)Creates a matcher that matches if the examined object matches ALL of the specified matchers.static <T> Matcher<T>Matchers. allOf(Matcher<? super T>... matchers)Creates a matcher that matches if the examined object matches ALL of the specified matchers.static <T> Matcher<T>Matchers. allOf(Matcher<? super T> first, Matcher<? super T> second)Creates a matcher that matches if the examined object matches ALL of the specified matchers.static <T> Matcher<T>Matchers. allOf(Matcher<? super T> first, Matcher<? super T> second, Matcher<? super T> third)Creates a matcher that matches if the examined object matches ALL of the specified matchers.static <T> Matcher<T>Matchers. allOf(Matcher<? super T> first, Matcher<? super T> second, Matcher<? super T> third, Matcher<? super T> fourth)Creates a matcher that matches if the examined object matches ALL of the specified matchers.static <T> Matcher<T>Matchers. allOf(Matcher<? super T> first, Matcher<? super T> second, Matcher<? super T> third, Matcher<? super T> fourth, Matcher<? super T> fifth)Creates a matcher that matches if the examined object matches ALL of the specified matchers.static <T> Matcher<T>Matchers. allOf(Matcher<? super T> first, Matcher<? super T> second, Matcher<? super T> third, Matcher<? super T> fourth, Matcher<? super T> fifth, Matcher<? super T> sixth)Creates a matcher that matches if the examined object matches ALL of the specified matchers.static <K,V>
Matcher<java.util.Map<? extends K,? extends V>>Matchers. aMapWithSize(Matcher<? super java.lang.Integer> sizeMatcher)Creates a matcher forMaps that matches when thesize()method returns a value that satisfies the specified matcher.static <T> AnyOf<T>CoreMatchers. anyOf(Matcher<? super T>... matchers)Creates a matcher that matches if the examined object matches ANY of the specified matchers.static <T> AnyOf<T>Matchers. anyOf(Matcher<? super T>... matchers)Creates a matcher that matches if the examined object matches ANY of the specified matchers.static <T> AnyOf<T>Matchers. anyOf(Matcher<? super T> first, Matcher<? super T> second)Creates a matcher that matches if the examined object matches ANY of the specified matchers.static <T> AnyOf<T>Matchers. anyOf(Matcher<? super T> first, Matcher<? super T> second, Matcher<? super T> third)Creates a matcher that matches if the examined object matches ANY of the specified matchers.static <T> AnyOf<T>Matchers. anyOf(Matcher<? super T> first, Matcher<? super T> second, Matcher<? super T> third, Matcher<? super T> fourth)Creates a matcher that matches if the examined object matches ANY of the specified matchers.static <T> AnyOf<T>Matchers. anyOf(Matcher<? super T> first, Matcher<? super T> second, Matcher<? super T> third, Matcher<? super T> fourth, Matcher<? super T> fifth)Creates a matcher that matches if the examined object matches ANY of the specified matchers.static <T> AnyOf<T>Matchers. anyOf(Matcher<? super T> first, Matcher<? super T> second, Matcher<? super T> third, Matcher<? super T> fourth, Matcher<? super T> fifth, Matcher<? super T> sixth)Creates a matcher that matches if the examined object matches ANY of the specified matchers.static <T> IsArray<T>Matchers. array(Matcher<? super T>... elementMatchers)Creates a matcher that matches arrays whose elements are satisfied by the specified matchers.static <E> Matcher<E[]>Matchers. arrayContaining(Matcher<? super E>... itemMatchers)Creates a matcher for arrays that matches when each item in the examined array satisfies the corresponding matcher in the specified matchers.static <E> Matcher<E[]>Matchers. arrayContainingInAnyOrder(Matcher<? super E>... itemMatchers)Creates an order agnostic matcher for arrays that matches when each item in the examined array satisfies one matcher anywhere in the specified matchers.static <E> Matcher<E[]>Matchers. arrayWithSize(Matcher<? super java.lang.Integer> sizeMatcher)Creates a matcher for arrays that matches when thelengthof the array satisfies the specified matcher.static <T> voidMatcherAssert. assertThat(java.lang.String reason, T actual, Matcher<? super T> matcher)static <T> voidMatcherAssert. assertThat(T actual, Matcher<? super T> matcher)static <LHS> CombinableMatcher.CombinableBothMatcher<LHS>CoreMatchers. both(Matcher<? super LHS> matcher)Creates a matcher that matches when both of the specified matchers match the examined object.static <LHS> CombinableMatcher.CombinableBothMatcher<LHS>Matchers. both(Matcher<? super LHS> matcher)Creates a matcher that matches when both of the specified matchers match the examined object.static <E> Matcher<java.lang.Iterable<? extends E>>Matchers. contains(Matcher<? super E> itemMatcher)Creates a matcher forIterables that matches when a single pass over the examinedIterableyields a single item that satisfies the specified matcher.static <E> Matcher<java.lang.Iterable<? extends E>>Matchers. contains(Matcher<? super E>... itemMatchers)Creates a matcher forIterables that matches when a single pass over the examinedIterableyields a series of items, each satisfying the corresponding matcher in the specified matchers.static <T> Matcher<java.lang.Iterable<? extends T>>Matchers. containsInAnyOrder(Matcher<? super T>... itemMatchers)Creates an order agnostic matcher forIterables that matches when a single pass over the examinedIterableyields a series of items, each satisfying one matcher anywhere in the specified matchers.static <E> Matcher<java.lang.Iterable<? extends E>>Matchers. containsInRelativeOrder(Matcher<? super E>... itemMatchers)Creates a matcher forIterables that matches when a single pass over the examinedIterableyields a series of items, that each satisfying the corresponding matcher in the specified matchers, in the same relative order.static <T> Matcher<T>CoreMatchers. describedAs(java.lang.String description, Matcher<T> matcher, java.lang.Object... values)Wraps an existing matcher, overriding its description with that specified.static <T> Matcher<T>Matchers. describedAs(java.lang.String description, Matcher<T> matcher, java.lang.Object... values)Wraps an existing matcher, overriding its description with that specified.static <LHS> CombinableMatcher.CombinableEitherMatcher<LHS>CoreMatchers. either(Matcher<? super LHS> matcher)Creates a matcher that matches when either of the specified matchers match the examined object.static <LHS> CombinableMatcher.CombinableEitherMatcher<LHS>Matchers. either(Matcher<? super LHS> matcher)Creates a matcher that matches when either of the specified matchers match the examined object.static <U> Matcher<java.lang.Iterable<? extends U>>CoreMatchers. everyItem(Matcher<U> itemMatcher)Creates a matcher forIterables that only matches when a single pass over the examinedIterableyields items that are all matched by the specifieditemMatcher.static <U> Matcher<java.lang.Iterable<? extends U>>Matchers. everyItem(Matcher<U> itemMatcher)Creates a matcher forIterables that only matches when a single pass over the examinedIterableyields items that are all matched by the specifieditemMatcher.static <K,V>
Matcher<java.util.Map<? extends K,? extends V>>Matchers. hasEntry(Matcher<? super K> keyMatcher, Matcher<? super V> valueMatcher)Creates a matcher forMaps matching when the examinedMapcontains at least one entry whose key satisfies the specifiedkeyMatcherand whose value satisfies the specifiedvalueMatcher.static <T> Matcher<java.lang.Iterable<? super T>>CoreMatchers. hasItem(Matcher<? super T> itemMatcher)Creates a matcher forIterables that only matches when a single pass over the examinedIterableyields at least one item that is matched by the specifieditemMatcher.static <T> Matcher<java.lang.Iterable<? super T>>Matchers. hasItem(Matcher<? super T> itemMatcher)Creates a matcher forIterables that only matches when a single pass over the examinedIterableyields at least one item that is matched by the specifieditemMatcher.static <T> Matcher<T[]>Matchers. hasItemInArray(Matcher<? super T> elementMatcher)Creates a matcher for arrays that matches when the examined array contains at least one item that is matched by the specifiedelementMatcher.static <T> Matcher<java.lang.Iterable<T>>CoreMatchers. hasItems(Matcher<? super T>... itemMatchers)Creates a matcher forIterables that matches when consecutive passes over the examinedIterableyield at least one item that is matched by the corresponding matcher from the specifieditemMatchers.static <T> Matcher<java.lang.Iterable<T>>Matchers. hasItems(Matcher<? super T>... itemMatchers)Creates a matcher forIterables that matches when consecutive passes over the examinedIterableyield at least one item that is matched by the corresponding matcher from the specifieditemMatchers.static <K> Matcher<java.util.Map<? extends K,?>>Matchers. hasKey(Matcher<? super K> keyMatcher)Creates a matcher forMaps matching when the examinedMapcontains at least one key that satisfies the specified matcher.static Matcher<java.lang.CharSequence>Matchers. hasLength(Matcher<? super java.lang.Integer> lengthMatcher)Creates a matcher ofCharSequencethat matches when a char sequence has the length that satisfies the specified matcher.static <T> Matcher<T>Matchers. hasProperty(java.lang.String propertyName, Matcher<?> valueMatcher)Creates a matcher that matches when the examined object has a JavaBean property with the specified name whose value satisfies the specified matcher.static <E> Matcher<java.util.Collection<? extends E>>Matchers. hasSize(Matcher<? super java.lang.Integer> sizeMatcher)Creates a matcher forCollections that matches when thesize()method returns a value that satisfies the specified matcher.static <T> Matcher<T>Matchers. hasToString(Matcher<? super java.lang.String> toStringMatcher)Creates a matcher that matches any examined object whosetoStringmethod returns a value that satisfies the specified matcher.static <V> Matcher<java.util.Map<?,? extends V>>Matchers. hasValue(Matcher<? super V> valueMatcher)Creates a matcher forMaps matching when the examinedMapcontains at least one value that satisfies the specified valueMatcher.static Matcher<org.w3c.dom.Node>Matchers. hasXPath(java.lang.String xPath, javax.xml.namespace.NamespaceContext namespaceContext, Matcher<java.lang.String> valueMatcher)Creates a matcher ofNodes that matches when the examined node has a value at the specifiedxPath, within the specifiednamespaceContext, that satisfies the specifiedvalueMatcher.static Matcher<org.w3c.dom.Node>Matchers. hasXPath(java.lang.String xPath, Matcher<java.lang.String> valueMatcher)Creates a matcher ofNodes that matches when the examined node has a value at the specifiedxPaththat satisfies the specifiedvalueMatcher.static <T> Matcher<T>CoreMatchers. is(Matcher<T> matcher)Decorates another Matcher, retaining its behaviour, but allowing tests to be slightly more expressive.static <T> Matcher<T>Matchers. is(Matcher<T> matcher)Decorates another Matcher, retaining its behaviour, but allowing tests to be slightly more expressive.static <E> Matcher<java.lang.Iterable<E>>Matchers. iterableWithSize(Matcher<? super java.lang.Integer> sizeMatcher)Creates a matcher forIterables that matches when a single pass over the examinedIterableyields an item count that satisfies the specified matcher.booleanCondition. matching(Matcher<T> match)abstract booleanCondition. matching(Matcher<T> match, java.lang.String message)static <T> Matcher<T>CoreMatchers. not(Matcher<T> matcher)Creates a matcher that wraps an existing matcher, but inverts the logic by which it will match.static <T> Matcher<T>Matchers. not(Matcher<T> matcher)Creates a matcher that wraps an existing matcher, but inverts the logic by which it will match.Method parameters in org.hamcrest with type arguments of type Matcher Modifier and Type Method Description static <T> Matcher<T>CoreMatchers. allOf(java.lang.Iterable<Matcher<? super T>> matchers)Creates a matcher that matches if the examined object matches ALL of the specified matchers.static <T> Matcher<T>Matchers. allOf(java.lang.Iterable<Matcher<? super T>> matchers)Creates a matcher that matches if the examined object matches ALL of the specified matchers.static <T> AnyOf<T>CoreMatchers. anyOf(java.lang.Iterable<Matcher<? super T>> matchers)Creates a matcher that matches if the examined object matches ANY of the specified matchers.static <T> AnyOf<T>Matchers. anyOf(java.lang.Iterable<Matcher<? super T>> matchers)Creates a matcher that matches if the examined object matches ANY of the specified matchers.static <E> Matcher<E[]>Matchers. arrayContaining(java.util.List<Matcher<? super E>> itemMatchers)Creates a matcher for arrays that matches when each item in the examined array satisfies the corresponding matcher in the specified list of matchers.static <E> Matcher<E[]>Matchers. arrayContainingInAnyOrder(java.util.Collection<Matcher<? super E>> itemMatchers)Creates an order agnostic matcher for arrays that matches when each item in the examined array satisfies one matcher anywhere in the specified collection of matchers.static <E> Matcher<java.lang.Iterable<? extends E>>Matchers. contains(java.util.List<Matcher<? super E>> itemMatchers)Creates a matcher forIterables that matches when a single pass over the examinedIterableyields a series of items, each satisfying the corresponding matcher in the specified list of matchers.static <T> Matcher<java.lang.Iterable<? extends T>>Matchers. containsInAnyOrder(java.util.Collection<Matcher<? super T>> itemMatchers)Creates an order agnostic matcher forIterables that matches when a single pass over the examinedIterableyields a series of items, each satisfying one matcher anywhere in the specified collection of matchers.static <E> Matcher<java.lang.Iterable<? extends E>>Matchers. containsInRelativeOrder(java.util.List<Matcher<? super E>> itemMatchers)Creates a matcher forIterables that matches when a single pass over the examinedIterableyields a series of items, that contains items satisfying the corresponding matcher in the specified list of matchers, in the same relative order.Constructors in org.hamcrest with parameters of type Matcher Constructor Description FeatureMatcher(Matcher<? super U> subMatcher, java.lang.String featureDescription, java.lang.String featureName)Constructor -
Uses of Matcher in org.hamcrest.beans
Classes in org.hamcrest.beans that implement Matcher Modifier and Type Class Description classHasProperty<T>A Matcher that checks that an object has a JavaBean property with the specified name.classHasPropertyWithValue<T>Matcher that asserts that a JavaBean property on an argument passed to the mock object meets the provided matcher.classSamePropertyValuesAs<T>Methods in org.hamcrest.beans that return Matcher Modifier and Type Method Description static <T> Matcher<T>HasProperty. hasProperty(java.lang.String propertyName)Creates a matcher that matches when the examined object has a JavaBean property with the specified name.static <T> Matcher<T>HasPropertyWithValue. hasProperty(java.lang.String propertyName, Matcher<?> valueMatcher)Creates a matcher that matches when the examined object has a JavaBean property with the specified name whose value satisfies the specified matcher.static <T> Matcher<T>HasPropertyWithValue. hasPropertyAtPath(java.lang.String path, Matcher<T> valueMatcher)Creates a matcher that matches when the examined object is a graph of JavaBean objects that can be navigated along the declared dot-separated path and the final element of that path is a JavaBean property whose value satisfies the specified matcher.static <B> Matcher<B>SamePropertyValuesAs. samePropertyValuesAs(B expectedBean, java.lang.String... ignoredProperties)Creates a matcher that matches when the examined object has values for all of its JavaBean properties that are equal to the corresponding values of the specified bean.Methods in org.hamcrest.beans with parameters of type Matcher Modifier and Type Method Description static <T> Matcher<T>HasPropertyWithValue. hasProperty(java.lang.String propertyName, Matcher<?> valueMatcher)Creates a matcher that matches when the examined object has a JavaBean property with the specified name whose value satisfies the specified matcher.static <T> Matcher<T>HasPropertyWithValue. hasPropertyAtPath(java.lang.String path, Matcher<T> valueMatcher)Creates a matcher that matches when the examined object is a graph of JavaBean objects that can be navigated along the declared dot-separated path and the final element of that path is a JavaBean property whose value satisfies the specified matcher.Constructors in org.hamcrest.beans with parameters of type Matcher Constructor Description HasPropertyWithValue(java.lang.String propertyName, Matcher<?> valueMatcher)HasPropertyWithValue(java.lang.String propertyName, Matcher<?> valueMatcher, java.lang.String messageFormat) -
Uses of Matcher in org.hamcrest.collection
Classes in org.hamcrest.collection that implement Matcher Modifier and Type Class Description classArrayAsIterableMatcher<E>classHasItemInArray<T>Matches if an array contains an item satisfying a nested matcher.classIsArray<T>Matcher for array whose elements satisfy a sequence of matchers.classIsArrayContainingInAnyOrder<E>Deprecated.As of release 2.1, replaced byArrayMatching.classIsArrayContainingInOrder<E>Deprecated.As of release 2.1, replaced byArrayMatching.classIsArrayWithSize<E>Matches if array size satisfies a nested matcher.classIsCollectionWithSize<E>Matches if collection size satisfies a nested matcher.classIsEmptyCollection<E>Tests if collection is empty.classIsEmptyIterable<E>Tests if collection is empty.classIsIn<T>classIsIterableContainingInAnyOrder<T>classIsIterableContainingInOrder<E>classIsIterableContainingInRelativeOrder<E>classIsIterableWithSize<E>classIsMapContaining<K,V>classIsMapWithSize<K,V>Matches if map size satisfies a nested matcher.Fields in org.hamcrest.collection with type parameters of type Matcher Modifier and Type Field Description protected java.util.Collection<Matcher<? super E>>ArrayAsIterableMatcher. matchersMethods in org.hamcrest.collection that return Matcher Modifier and Type Method Description static <K,V>
Matcher<java.util.Map<? extends K,? extends V>>IsMapWithSize. aMapWithSize(int size)Creates a matcher forMaps that matches when thesize()method returns a value equal to the specifiedsize.static <K,V>
Matcher<java.util.Map<? extends K,? extends V>>IsMapWithSize. aMapWithSize(Matcher<? super java.lang.Integer> sizeMatcher)Creates a matcher forMaps that matches when thesize()method returns a value that satisfies the specified matcher.static <K,V>
Matcher<java.util.Map<? extends K,? extends V>>IsMapWithSize. anEmptyMap()Creates a matcher forMaps that matches when thesize()method returns zero.static <E> Matcher<E[]>ArrayMatching. arrayContaining(E... items)Creates a matcher for arrays that matches when each item in the examined array is logically equal to the corresponding item in the specified items.static <E> Matcher<E[]>ArrayMatching. arrayContaining(java.util.List<Matcher<? super E>> itemMatchers)Creates a matcher for arrays that matches when each item in the examined array satisfies the corresponding matcher in the specified list of matchers.static <E> Matcher<E[]>ArrayMatching. arrayContaining(Matcher<? super E>... itemMatchers)Creates a matcher for arrays that matches when each item in the examined array satisfies the corresponding matcher in the specified matchers.static <E> Matcher<E[]>IsArrayContainingInOrder. arrayContaining(E... items)Deprecated.As of version 2.1, useArrayMatching.arrayContaining(Object[]).static <E> Matcher<E[]>IsArrayContainingInOrder. arrayContaining(java.util.List<Matcher<? super E>> itemMatchers)Deprecated.As of version 2.1, useArrayMatching.arrayContaining(List).static <E> Matcher<E[]>IsArrayContainingInOrder. arrayContaining(Matcher<? super E>... itemMatchers)Deprecated.As of version 2.1, useArrayMatching.arrayContaining(Matcher[]).static <E> Matcher<E[]>ArrayMatching. arrayContainingInAnyOrder(E... items)Creates an order agnostic matcher for arrays that matches when each item in the examined array is logically equal to one item anywhere in the specified items.static <E> Matcher<E[]>ArrayMatching. arrayContainingInAnyOrder(java.util.Collection<Matcher<? super E>> itemMatchers)Creates an order agnostic matcher for arrays that matches when each item in the examined array satisfies one matcher anywhere in the specified collection of matchers.static <E> Matcher<E[]>ArrayMatching. arrayContainingInAnyOrder(Matcher<? super E>... itemMatchers)Creates an order agnostic matcher for arrays that matches when each item in the examined array satisfies one matcher anywhere in the specified matchers.static <E> Matcher<E[]>IsArrayContainingInAnyOrder. arrayContainingInAnyOrder(E... items)Deprecated.As of version 2.1, useArrayMatching.arrayContainingInAnyOrder(Object[]).static <E> Matcher<E[]>IsArrayContainingInAnyOrder. arrayContainingInAnyOrder(java.util.Collection<Matcher<? super E>> itemMatchers)Deprecated.As of version 2.1, useArrayMatching.arrayContainingInAnyOrder(Collection).static <E> Matcher<E[]>IsArrayContainingInAnyOrder. arrayContainingInAnyOrder(Matcher<? super E>... itemMatchers)Deprecated.As of version 2.1, useArrayMatching.arrayContainingInAnyOrder(Matcher[]).static <E> Matcher<E[]>IsArrayWithSize. arrayWithSize(int size)Creates a matcher for arrays that matches when thelengthof the array equals the specifiedsize.static <E> Matcher<E[]>IsArrayWithSize. arrayWithSize(Matcher<? super java.lang.Integer> sizeMatcher)Creates a matcher for arrays that matches when thelengthof the array satisfies the specified matcher.static <E> Matcher<java.lang.Iterable<? extends E>>IsIterableContainingInOrder. contains(E... items)Creates a matcher forIterables that matches when a single pass over the examinedIterableyields a series of items, each logically equal to the corresponding item in the specified items.static <E> Matcher<java.lang.Iterable<? extends E>>IsIterableContainingInOrder. contains(java.util.List<Matcher<? super E>> itemMatchers)Creates a matcher forIterables that matches when a single pass over the examinedIterableyields a series of items, each satisfying the corresponding matcher in the specified list of matchers.static <E> Matcher<java.lang.Iterable<? extends E>>IsIterableContainingInOrder. contains(Matcher<? super E> itemMatcher)Creates a matcher forIterables that matches when a single pass over the examinedIterableyields a single item that satisfies the specified matcher.static <E> Matcher<java.lang.Iterable<? extends E>>IsIterableContainingInOrder. contains(Matcher<? super E>... itemMatchers)Creates a matcher forIterables that matches when a single pass over the examinedIterableyields a series of items, each satisfying the corresponding matcher in the specified matchers.static <T> Matcher<java.lang.Iterable<? extends T>>IsIterableContainingInAnyOrder. containsInAnyOrder(java.util.Collection<Matcher<? super T>> itemMatchers)Creates an order agnostic matcher forIterables that matches when a single pass over the examinedIterableyields a series of items, each satisfying one matcher anywhere in the specified collection of matchers.static <T> Matcher<java.lang.Iterable<? extends T>>IsIterableContainingInAnyOrder. containsInAnyOrder(Matcher<? super T>... itemMatchers)Creates an order agnostic matcher forIterables that matches when a single pass over the examinedIterableyields a series of items, each satisfying one matcher anywhere in the specified matchers.static <T> Matcher<java.lang.Iterable<? extends T>>IsIterableContainingInAnyOrder. containsInAnyOrder(T... items)Creates an order agnostic matcher forIterables that matches when a single pass over the examinedIterableyields a series of items, each logically equal to one item anywhere in the specified items.static <E> Matcher<java.lang.Iterable<? extends E>>IsIterableContainingInRelativeOrder. containsInRelativeOrder(E... items)Creates a matcher forIterables that matches when a single pass over the examinedIterableyields a series of items, that contains items logically equal to the corresponding item in the specified items, in the same relative order For example:static <E> Matcher<java.lang.Iterable<? extends E>>IsIterableContainingInRelativeOrder. containsInRelativeOrder(java.util.List<Matcher<? super E>> itemMatchers)Creates a matcher forIterables that matches when a single pass over the examinedIterableyields a series of items, that contains items satisfying the corresponding matcher in the specified list of matchers, in the same relative order.static <E> Matcher<java.lang.Iterable<? extends E>>IsIterableContainingInRelativeOrder. containsInRelativeOrder(Matcher<? super E>... itemMatchers)Creates a matcher forIterables that matches when a single pass over the examinedIterableyields a series of items, that each satisfying the corresponding matcher in the specified matchers, in the same relative order.static <E> Matcher<java.util.Collection<? extends E>>IsEmptyCollection. empty()Creates a matcher forCollections matching examined collections whoseisEmptymethod returnstrue.static <E> Matcher<E[]>IsArrayWithSize. emptyArray()Creates a matcher for arrays that matches when thelengthof the array is zero.static <E> Matcher<java.util.Collection<E>>IsEmptyCollection. emptyCollectionOf(java.lang.Class<E> unusedToForceReturnType)Creates a matcher forCollections matching examined collections whoseisEmptymethod returnstrue.static <E> Matcher<java.lang.Iterable<? extends E>>IsEmptyIterable. emptyIterable()Creates a matcher forIterables matching examined iterables that yield no items.static <E> Matcher<java.lang.Iterable<E>>IsEmptyIterable. emptyIterableOf(java.lang.Class<E> unusedToForceReturnType)Creates a matcher forIterables matching examined iterables that yield no items.static <K,V>
Matcher<java.util.Map<? extends K,? extends V>>IsMapContaining. hasEntry(K key, V value)Creates a matcher forMaps matching when the examinedMapcontains at least one entry whose key equals the specifiedkeyand whose value equals the specifiedvalue.static <K,V>
Matcher<java.util.Map<? extends K,? extends V>>IsMapContaining. hasEntry(Matcher<? super K> keyMatcher, Matcher<? super V> valueMatcher)Creates a matcher forMaps matching when the examinedMapcontains at least one entry whose key satisfies the specifiedkeyMatcherand whose value satisfies the specifiedvalueMatcher.static <T> Matcher<T[]>ArrayMatching. hasItemInArray(Matcher<? super T> elementMatcher)Creates a matcher for arrays that matches when the examined array contains at least one item that is matched by the specifiedelementMatcher.static <T> Matcher<T[]>ArrayMatching. hasItemInArray(T element)A shortcut to the frequently usedhasItemInArray(equalTo(x)).static <K> Matcher<java.util.Map<? extends K,?>>IsMapContaining. hasKey(K key)Creates a matcher forMaps matching when the examinedMapcontains at least one key that is equal to the specified key.static <K> Matcher<java.util.Map<? extends K,?>>IsMapContaining. hasKey(Matcher<? super K> keyMatcher)Creates a matcher forMaps matching when the examinedMapcontains at least one key that satisfies the specified matcher.static <E> Matcher<java.util.Collection<? extends E>>IsCollectionWithSize. hasSize(int size)Creates a matcher forCollections that matches when thesize()method returns a value equal to the specifiedsize.static <E> Matcher<java.util.Collection<? extends E>>IsCollectionWithSize. hasSize(Matcher<? super java.lang.Integer> sizeMatcher)Creates a matcher forCollections that matches when thesize()method returns a value that satisfies the specified matcher.static <V> Matcher<java.util.Map<?,? extends V>>IsMapContaining. hasValue(Matcher<? super V> valueMatcher)Creates a matcher forMaps matching when the examinedMapcontains at least one value that satisfies the specified valueMatcher.static <V> Matcher<java.util.Map<?,? extends V>>IsMapContaining. hasValue(V value)Creates a matcher forMaps matching when the examinedMapcontains at least one value that is equal to the specified value.static <T> Matcher<T>IsIn. in(java.util.Collection<T> collection)Creates a matcher that matches when the examined object is found within the specified collection.static <T> Matcher<T>IsIn. in(T[] elements)Creates a matcher that matches when the examined object is found within the specified array.static <T> Matcher<T>IsIn. isIn(java.util.Collection<T> collection)Deprecated.use is(in(...)) insteadstatic <T> Matcher<T>IsIn. isIn(T[] elements)Deprecated.use is(in(...)) insteadstatic <T> Matcher<T>IsIn. isOneOf(T... elements)Deprecated.use is(oneOf(...)) insteadstatic <E> Matcher<java.lang.Iterable<E>>IsIterableWithSize. iterableWithSize(int size)Creates a matcher forIterables that matches when a single pass over the examinedIterableyields an item count that is equal to the specifiedsizeargument.static <E> Matcher<java.lang.Iterable<E>>IsIterableWithSize. iterableWithSize(Matcher<? super java.lang.Integer> sizeMatcher)Creates a matcher forIterables that matches when a single pass over the examinedIterableyields an item count that satisfies the specified matcher.static <T> Matcher<T>IsIn. oneOf(T... elements)Creates a matcher that matches when the examined object is equal to one of the specified elements.Methods in org.hamcrest.collection that return types with arguments of type Matcher Modifier and Type Method Description static <E> java.util.List<Matcher<? super E>>ArrayMatching. asEqualMatchers(E[] items)Methods in org.hamcrest.collection with parameters of type Matcher Modifier and Type Method Description static <K,V>
Matcher<java.util.Map<? extends K,? extends V>>IsMapWithSize. aMapWithSize(Matcher<? super java.lang.Integer> sizeMatcher)Creates a matcher forMaps that matches when thesize()method returns a value that satisfies the specified matcher.static <T> IsArray<T>IsArray. array(Matcher<? super T>... elementMatchers)Creates a matcher that matches arrays whose elements are satisfied by the specified matchers.static <E> Matcher<E[]>ArrayMatching. arrayContaining(Matcher<? super E>... itemMatchers)Creates a matcher for arrays that matches when each item in the examined array satisfies the corresponding matcher in the specified matchers.static <E> Matcher<E[]>IsArrayContainingInOrder. arrayContaining(Matcher<? super E>... itemMatchers)Deprecated.As of version 2.1, useArrayMatching.arrayContaining(Matcher[]).static <E> Matcher<E[]>ArrayMatching. arrayContainingInAnyOrder(Matcher<? super E>... itemMatchers)Creates an order agnostic matcher for arrays that matches when each item in the examined array satisfies one matcher anywhere in the specified matchers.static <E> Matcher<E[]>IsArrayContainingInAnyOrder. arrayContainingInAnyOrder(Matcher<? super E>... itemMatchers)Deprecated.As of version 2.1, useArrayMatching.arrayContainingInAnyOrder(Matcher[]).static <E> Matcher<E[]>IsArrayWithSize. arrayWithSize(Matcher<? super java.lang.Integer> sizeMatcher)Creates a matcher for arrays that matches when thelengthof the array satisfies the specified matcher.static <E> Matcher<java.lang.Iterable<? extends E>>IsIterableContainingInOrder. contains(Matcher<? super E> itemMatcher)Creates a matcher forIterables that matches when a single pass over the examinedIterableyields a single item that satisfies the specified matcher.static <E> Matcher<java.lang.Iterable<? extends E>>IsIterableContainingInOrder. contains(Matcher<? super E>... itemMatchers)Creates a matcher forIterables that matches when a single pass over the examinedIterableyields a series of items, each satisfying the corresponding matcher in the specified matchers.static <T> Matcher<java.lang.Iterable<? extends T>>IsIterableContainingInAnyOrder. containsInAnyOrder(Matcher<? super T>... itemMatchers)Creates an order agnostic matcher forIterables that matches when a single pass over the examinedIterableyields a series of items, each satisfying one matcher anywhere in the specified matchers.static <E> Matcher<java.lang.Iterable<? extends E>>IsIterableContainingInRelativeOrder. containsInRelativeOrder(Matcher<? super E>... itemMatchers)Creates a matcher forIterables that matches when a single pass over the examinedIterableyields a series of items, that each satisfying the corresponding matcher in the specified matchers, in the same relative order.static <K,V>
Matcher<java.util.Map<? extends K,? extends V>>IsMapContaining. hasEntry(Matcher<? super K> keyMatcher, Matcher<? super V> valueMatcher)Creates a matcher forMaps matching when the examinedMapcontains at least one entry whose key satisfies the specifiedkeyMatcherand whose value satisfies the specifiedvalueMatcher.static <T> Matcher<T[]>ArrayMatching. hasItemInArray(Matcher<? super T> elementMatcher)Creates a matcher for arrays that matches when the examined array contains at least one item that is matched by the specifiedelementMatcher.static <K> Matcher<java.util.Map<? extends K,?>>IsMapContaining. hasKey(Matcher<? super K> keyMatcher)Creates a matcher forMaps matching when the examinedMapcontains at least one key that satisfies the specified matcher.static <E> Matcher<java.util.Collection<? extends E>>IsCollectionWithSize. hasSize(Matcher<? super java.lang.Integer> sizeMatcher)Creates a matcher forCollections that matches when thesize()method returns a value that satisfies the specified matcher.static <V> Matcher<java.util.Map<?,? extends V>>IsMapContaining. hasValue(Matcher<? super V> valueMatcher)Creates a matcher forMaps matching when the examinedMapcontains at least one value that satisfies the specified valueMatcher.static <E> Matcher<java.lang.Iterable<E>>IsIterableWithSize. iterableWithSize(Matcher<? super java.lang.Integer> sizeMatcher)Creates a matcher forIterables that matches when a single pass over the examinedIterableyields an item count that satisfies the specified matcher.Method parameters in org.hamcrest.collection with type arguments of type Matcher Modifier and Type Method Description static <E> Matcher<E[]>ArrayMatching. arrayContaining(java.util.List<Matcher<? super E>> itemMatchers)Creates a matcher for arrays that matches when each item in the examined array satisfies the corresponding matcher in the specified list of matchers.static <E> Matcher<E[]>IsArrayContainingInOrder. arrayContaining(java.util.List<Matcher<? super E>> itemMatchers)Deprecated.As of version 2.1, useArrayMatching.arrayContaining(List).static <E> Matcher<E[]>ArrayMatching. arrayContainingInAnyOrder(java.util.Collection<Matcher<? super E>> itemMatchers)Creates an order agnostic matcher for arrays that matches when each item in the examined array satisfies one matcher anywhere in the specified collection of matchers.static <E> Matcher<E[]>IsArrayContainingInAnyOrder. arrayContainingInAnyOrder(java.util.Collection<Matcher<? super E>> itemMatchers)Deprecated.As of version 2.1, useArrayMatching.arrayContainingInAnyOrder(Collection).static <E> Matcher<java.lang.Iterable<? extends E>>IsIterableContainingInOrder. contains(java.util.List<Matcher<? super E>> itemMatchers)Creates a matcher forIterables that matches when a single pass over the examinedIterableyields a series of items, each satisfying the corresponding matcher in the specified list of matchers.static <T> Matcher<java.lang.Iterable<? extends T>>IsIterableContainingInAnyOrder. containsInAnyOrder(java.util.Collection<Matcher<? super T>> itemMatchers)Creates an order agnostic matcher forIterables that matches when a single pass over the examinedIterableyields a series of items, each satisfying one matcher anywhere in the specified collection of matchers.static <E> Matcher<java.lang.Iterable<? extends E>>IsIterableContainingInRelativeOrder. containsInRelativeOrder(java.util.List<Matcher<? super E>> itemMatchers)Creates a matcher forIterables that matches when a single pass over the examinedIterableyields a series of items, that contains items satisfying the corresponding matcher in the specified list of matchers, in the same relative order.Constructors in org.hamcrest.collection with parameters of type Matcher Constructor Description HasItemInArray(Matcher<? super T> elementMatcher)IsArray(Matcher<? super T>[] elementMatchers)IsArrayWithSize(Matcher<? super java.lang.Integer> sizeMatcher)IsCollectionWithSize(Matcher<? super java.lang.Integer> sizeMatcher)IsIterableWithSize(Matcher<? super java.lang.Integer> sizeMatcher)IsMapContaining(Matcher<? super K> keyMatcher, Matcher<? super V> valueMatcher)IsMapWithSize(Matcher<? super java.lang.Integer> sizeMatcher)Constructor parameters in org.hamcrest.collection with type arguments of type Matcher Constructor Description ArrayAsIterableMatcher(TypeSafeDiagnosingMatcher<java.lang.Iterable<? extends E>> iterableMatcher, java.util.Collection<Matcher<? super E>> matchers, java.lang.String message)IsArrayContainingInAnyOrder(java.util.Collection<Matcher<? super E>> matchers)Deprecated.IsArrayContainingInOrder(java.util.List<Matcher<? super E>> matchers)Deprecated.IsIterableContainingInAnyOrder(java.util.Collection<Matcher<? super T>> matchers)IsIterableContainingInOrder(java.util.List<Matcher<? super E>> matchers)IsIterableContainingInRelativeOrder(java.util.List<Matcher<? super E>> matchers) -
Uses of Matcher in org.hamcrest.comparator
Methods in org.hamcrest.comparator that return Matcher Modifier and Type Method Description Matcher<T>ComparatorMatcherBuilder. comparesEqualTo(T value)Creates a matcher ofTobject that matches when the examined object is equal to the specified value, as reported by theComparatorused to create this builder.Matcher<T>ComparatorMatcherBuilder. greaterThan(T value)Creates a matcher ofTobject that matches when the examined object is greater than the specified value, as reported by theComparatorused to create this builder.Matcher<T>ComparatorMatcherBuilder. greaterThanOrEqualTo(T value)Creates a matcher ofTobject that matches when the examined object is greater than or equal to the specified value, as reported by theComparatorused to create this builder.Matcher<T>ComparatorMatcherBuilder. lessThan(T value)Creates a matcher ofTobject that matches when the examined object is less than the specified value, as reported by theComparatorused to create this builder.Matcher<T>ComparatorMatcherBuilder. lessThanOrEqualTo(T value)Creates a matcher ofTobject that matches when the examined object is less than or equal to the specified value, as reported by theComparatorused to create this builder. -
Uses of Matcher in org.hamcrest.core
Classes in org.hamcrest.core that implement Matcher Modifier and Type Class Description classAllOf<T>Calculates the logical conjunction of multiple matchers.classAnyOf<T>Calculates the logical disjunction of multiple matchers.classCombinableMatcher<T>TODO: Finish Class Level Documentation.classDescribedAs<T>Provides a custom description to another matcher.classEvery<T>classIs<T>Decorates another Matcher, retaining the behaviour but allowing tests to be slightly more expressive.classIsAnything<T>A matcher that always returnstrue.classIsCollectionContaining<T>Deprecated.As of release 2.1, replaced byIsIterableContaining.classIsEqual<T>Is the value equal to another value, as tested by theObject.equals(java.lang.Object)invokedMethod?classIsInstanceOfTests whether the value is an instance of a class.classIsIterableContaining<T>classIsNot<T>Calculates the logical negation of a matcher.classIsNull<T>Is the value null?classIsSame<T>Is the value the same object as another value?classStringContainsTests if the argument is a string that contains a specific substring.classStringEndsWithTests if the argument is a string that ends with a specific substring.classStringRegularExpressionclassStringStartsWithTests if the argument is a string that starts with a specific substring.classSubstringMatcherMethods in org.hamcrest.core that return Matcher Modifier and Type Method Description static <T> Matcher<T>AllOf. allOf(java.lang.Iterable<Matcher<? super T>> matchers)Creates a matcher that matches if the examined object matches ALL of the specified matchers.static <T> Matcher<T>AllOf. allOf(Matcher<? super T>... matchers)Creates a matcher that matches if the examined object matches ALL of the specified matchers.static <T> Matcher<T>IsInstanceOf. any(java.lang.Class<T> type)Creates a matcher that matches when the examined object is an instance of the specifiedtype, as determined by calling theClass.isInstance(Object)method on that type, passing the the examined object.static Matcher<java.lang.Object>IsAnything. anything()Creates a matcher that always matches, regardless of the examined object.static Matcher<java.lang.Object>IsAnything. anything(java.lang.String description)Creates a matcher that always matches, regardless of the examined object, but describes itself with the specifiedString.static Matcher<java.lang.String>StringContains. containsString(java.lang.String substring)Creates a matcher that matches if the examinedStringcontains the specifiedStringanywhere.static Matcher<java.lang.String>StringContains. containsStringIgnoringCase(java.lang.String substring)Creates a matcher that matches if the examinedStringcontains the specifiedStringanywhere, ignoring case.static <T> Matcher<T>DescribedAs. describedAs(java.lang.String description, Matcher<T> matcher, java.lang.Object... values)Wraps an existing matcher, overriding its description with that specified.static Matcher<java.lang.String>StringEndsWith. endsWith(java.lang.String suffix)Creates a matcher that matches if the examinedStringends with the specifiedString.static Matcher<java.lang.String>StringEndsWith. endsWithIgnoringCase(java.lang.String suffix)Creates a matcher that matches if the examinedStringends with the specifiedString, ignoring case.static <T> Matcher<T>IsEqual. equalTo(T operand)Creates a matcher that matches when the examined object is logically equal to the specifiedoperand, as determined by calling theObject.equals(java.lang.Object)method on the examined object.static Matcher<java.lang.Object>IsEqual. equalToObject(java.lang.Object operand)Creates anIsEqualmatcher that does not enforce the values being compared to be of the same static type.static <U> Matcher<java.lang.Iterable<? extends U>>Every. everyItem(Matcher<U> itemMatcher)Creates a matcher forIterables that only matches when a single pass over the examinedIterableyields items that are all matched by the specifieditemMatcher.static <T> Matcher<java.lang.Iterable<? super T>>IsCollectionContaining. hasItem(Matcher<? super T> itemMatcher)Deprecated.As of version 2.1, useIsIterableContaining.hasItem(Matcher).static <T> Matcher<java.lang.Iterable<? super T>>IsCollectionContaining. hasItem(T item)Deprecated.As of version 2.1, useIsIterableContaining.hasItem(Object).static <T> Matcher<java.lang.Iterable<? super T>>IsIterableContaining. hasItem(Matcher<? super T> itemMatcher)Creates a matcher forIterables that only matches when a single pass over the examinedIterableyields at least one item that is matched by the specifieditemMatcher.static <T> Matcher<java.lang.Iterable<? super T>>IsIterableContaining. hasItem(T item)Creates a matcher forIterables that only matches when a single pass over the examinedIterableyields at least one item that is equal to the specifieditem.static <T> Matcher<java.lang.Iterable<T>>IsCollectionContaining. hasItems(Matcher<? super T>... itemMatchers)Deprecated.As of version 2.1, useIsIterableContaining.hasItems(Matcher[])}.static <T> Matcher<java.lang.Iterable<T>>IsCollectionContaining. hasItems(T... items)Deprecated.As of version 2.1, useIsIterableContaining.hasItems(Object[])}.static <T> Matcher<java.lang.Iterable<T>>IsIterableContaining. hasItems(Matcher<? super T>... itemMatchers)Creates a matcher forIterables that matches when consecutive passes over the examinedIterableyield at least one item that is matched by the corresponding matcher from the specifieditemMatchers.static <T> Matcher<java.lang.Iterable<T>>IsIterableContaining. hasItems(T... items)Creates a matcher forIterables that matches when consecutive passes over the examinedIterableyield at least one item that is equal to the corresponding item from the specifieditems.static <T> Matcher<T>IsInstanceOf. instanceOf(java.lang.Class<?> type)Creates a matcher that matches when the examined object is an instance of the specifiedtype, as determined by calling theClass.isInstance(Object)method on that type, passing the the examined object.static <T> Matcher<T>Is. is(Matcher<T> matcher)Decorates another Matcher, retaining its behaviour, but allowing tests to be slightly more expressive.static <T> Matcher<T>Is. is(T value)A shortcut to the frequently usedis(equalTo(x)).static <T> Matcher<T>Is. isA(java.lang.Class<?> type)A shortcut to the frequently usedis(instanceOf(SomeClass.class)).static Matcher<java.lang.String>StringRegularExpression. matchesRegex(java.lang.String regex)Creates a matcher that checks if the examined string matches a specified regex.static Matcher<java.lang.String>StringRegularExpression. matchesRegex(java.util.regex.Pattern pattern)Creates a matcher that checks if the examined string matches a specifiedPattern.static <T> Matcher<T>IsNot. not(Matcher<T> matcher)Creates a matcher that wraps an existing matcher, but inverts the logic by which it will match.static <T> Matcher<T>IsNot. not(T value)A shortcut to the frequently usednot(equalTo(x)).static Matcher<java.lang.Object>IsNull. notNullValue()A shortcut to the frequently usednot(nullValue()).static <T> Matcher<T>IsNull. notNullValue(java.lang.Class<T> type)A shortcut to the frequently usednot(nullValue(X.class)).static Matcher<java.lang.Object>IsNull. nullValue()Creates a matcher that matches if examined object isnull.static <T> Matcher<T>IsNull. nullValue(java.lang.Class<T> type)Creates a matcher that matches if examined object isnull.static <T> Matcher<T>IsSame. sameInstance(T target)Creates a matcher that matches only when the examined object is the same instance as the specified target object.static Matcher<java.lang.String>StringStartsWith. startsWith(java.lang.String prefix)Creates a matcher that matches if the examinedStringstarts with the specifiedString.static Matcher<java.lang.String>StringStartsWith. startsWithIgnoringCase(java.lang.String prefix)Creates a matcher that matches if the examinedStringstarts with the specifiedString, ignoring casestatic <T> Matcher<T>IsSame. theInstance(T target)Creates a matcher that matches only when the examined object is the same instance as the specified target object.Methods in org.hamcrest.core with parameters of type Matcher Modifier and Type Method Description static <T> Matcher<T>AllOf. allOf(Matcher<? super T>... matchers)Creates a matcher that matches if the examined object matches ALL of the specified matchers.CombinableMatcher<T>CombinableMatcher. and(Matcher<? super T> other)CombinableMatcher<X>CombinableMatcher.CombinableBothMatcher. and(Matcher<? super X> other)static <T> AnyOf<T>AnyOf. anyOf(Matcher<? super T>... matchers)Creates a matcher that matches if the examined object matches ANY of the specified matchers.static <LHS> CombinableMatcher.CombinableBothMatcher<LHS>CombinableMatcher. both(Matcher<? super LHS> matcher)Creates a matcher that matches when both of the specified matchers match the examined object.static <T> Matcher<T>DescribedAs. describedAs(java.lang.String description, Matcher<T> matcher, java.lang.Object... values)Wraps an existing matcher, overriding its description with that specified.static <LHS> CombinableMatcher.CombinableEitherMatcher<LHS>CombinableMatcher. either(Matcher<? super LHS> matcher)Creates a matcher that matches when either of the specified matchers match the examined object.static <U> Matcher<java.lang.Iterable<? extends U>>Every. everyItem(Matcher<U> itemMatcher)Creates a matcher forIterables that only matches when a single pass over the examinedIterableyields items that are all matched by the specifieditemMatcher.static <T> Matcher<java.lang.Iterable<? super T>>IsCollectionContaining. hasItem(Matcher<? super T> itemMatcher)Deprecated.As of version 2.1, useIsIterableContaining.hasItem(Matcher).static <T> Matcher<java.lang.Iterable<? super T>>IsIterableContaining. hasItem(Matcher<? super T> itemMatcher)Creates a matcher forIterables that only matches when a single pass over the examinedIterableyields at least one item that is matched by the specifieditemMatcher.static <T> Matcher<java.lang.Iterable<T>>IsCollectionContaining. hasItems(Matcher<? super T>... itemMatchers)Deprecated.As of version 2.1, useIsIterableContaining.hasItems(Matcher[])}.static <T> Matcher<java.lang.Iterable<T>>IsIterableContaining. hasItems(Matcher<? super T>... itemMatchers)Creates a matcher forIterables that matches when consecutive passes over the examinedIterableyield at least one item that is matched by the corresponding matcher from the specifieditemMatchers.static <T> Matcher<T>Is. is(Matcher<T> matcher)Decorates another Matcher, retaining its behaviour, but allowing tests to be slightly more expressive.static <T> Matcher<T>IsNot. not(Matcher<T> matcher)Creates a matcher that wraps an existing matcher, but inverts the logic by which it will match.CombinableMatcher<X>CombinableMatcher.CombinableEitherMatcher. or(Matcher<? super X> other)CombinableMatcher<T>CombinableMatcher. or(Matcher<? super T> other)Method parameters in org.hamcrest.core with type arguments of type Matcher Modifier and Type Method Description static <T> Matcher<T>AllOf. allOf(java.lang.Iterable<Matcher<? super T>> matchers)Creates a matcher that matches if the examined object matches ALL of the specified matchers.static <T> AnyOf<T>AnyOf. anyOf(java.lang.Iterable<Matcher<? super T>> matchers)Creates a matcher that matches if the examined object matches ANY of the specified matchers.Constructors in org.hamcrest.core with parameters of type Matcher Constructor Description AllOf(Matcher<? super T>... matchers)AnyOf(Matcher<? super T>... matchers)CombinableBothMatcher(Matcher<? super X> matcher)CombinableEitherMatcher(Matcher<? super X> matcher)CombinableMatcher(Matcher<? super T> matcher)DescribedAs(java.lang.String descriptionTemplate, Matcher<T> matcher, java.lang.Object[] values)Every(Matcher<? super T> matcher)Is(Matcher<T> matcher)IsCollectionContaining(Matcher<? super T> elementMatcher)Deprecated.IsIterableContaining(Matcher<? super T> elementMatcher)IsNot(Matcher<T> matcher)Constructor parameters in org.hamcrest.core with type arguments of type Matcher Constructor Description AllOf(java.lang.Iterable<Matcher<? super T>> matchers)AnyOf(java.lang.Iterable<Matcher<? super T>> matchers) -
Uses of Matcher in org.hamcrest.internal
Methods in org.hamcrest.internal that return types with arguments of type Matcher Modifier and Type Method Description static <E> java.util.List<Matcher<? super E>>NullSafety. nullSafe(Matcher<? super E>[] itemMatchers)Methods in org.hamcrest.internal with parameters of type Matcher Modifier and Type Method Description static <E> java.util.List<Matcher<? super E>>NullSafety. nullSafe(Matcher<? super E>[] itemMatchers) -
Uses of Matcher in org.hamcrest.io
Methods in org.hamcrest.io that return Matcher Modifier and Type Method Description static Matcher<java.io.File>FileMatchers. aFileNamed(Matcher<java.lang.String> expected)static Matcher<java.io.File>FileMatchers. aFileWithAbsolutePath(Matcher<java.lang.String> expected)static Matcher<java.io.File>FileMatchers. aFileWithCanonicalPath(Matcher<java.lang.String> expected)static Matcher<java.io.File>FileMatchers. aFileWithSize(long size)static Matcher<java.io.File>FileMatchers. aFileWithSize(Matcher<java.lang.Long> expected)static Matcher<java.io.File>FileMatchers. anExistingDirectory()static Matcher<java.io.File>FileMatchers. anExistingFile()static Matcher<java.io.File>FileMatchers. anExistingFileOrDirectory()static Matcher<java.io.File>FileMatchers. aReadableFile()static Matcher<java.io.File>FileMatchers. aWritableFile()Methods in org.hamcrest.io with parameters of type Matcher Modifier and Type Method Description static Matcher<java.io.File>FileMatchers. aFileNamed(Matcher<java.lang.String> expected)static Matcher<java.io.File>FileMatchers. aFileWithAbsolutePath(Matcher<java.lang.String> expected)static Matcher<java.io.File>FileMatchers. aFileWithCanonicalPath(Matcher<java.lang.String> expected)static Matcher<java.io.File>FileMatchers. aFileWithSize(Matcher<java.lang.Long> expected) -
Uses of Matcher in org.hamcrest.number
Classes in org.hamcrest.number that implement Matcher Modifier and Type Class Description classBigDecimalCloseToclassIsCloseToIs the value a number equal to a value within some range of acceptable error?classIsNaNIs the value a number actually not a number (NaN)?Methods in org.hamcrest.number that return Matcher Modifier and Type Method Description static Matcher<java.math.BigDecimal>BigDecimalCloseTo. closeTo(java.math.BigDecimal operand, java.math.BigDecimal error)Creates a matcher ofBigDecimals that matches when an examined BigDecimal is equal to the specifiedoperand, within a range of +/-error.static Matcher<java.lang.Double>IsCloseTo. closeTo(double operand, double error)Creates a matcher ofDoubles that matches when an examined double is equal to the specifiedoperand, within a range of +/-error.static <T extends java.lang.Comparable<T>>
Matcher<T>OrderingComparison. comparesEqualTo(T value)Creates a matcher ofComparableobject that matches when the examined object is equal to the specified value, as reported by thecompareTomethod of the examined object.static <T extends java.lang.Comparable<T>>
Matcher<T>OrderingComparison. greaterThan(T value)Creates a matcher ofComparableobject that matches when the examined object is greater than the specified value, as reported by thecompareTomethod of the examined object.static <T extends java.lang.Comparable<T>>
Matcher<T>OrderingComparison. greaterThanOrEqualTo(T value)Creates a matcher ofComparableobject that matches when the examined object is greater than or equal to the specified value, as reported by thecompareTomethod of the examined object.static <T extends java.lang.Comparable<T>>
Matcher<T>OrderingComparison. lessThan(T value)Creates a matcher ofComparableobject that matches when the examined object is less than the specified value, as reported by thecompareTomethod of the examined object.static <T extends java.lang.Comparable<T>>
Matcher<T>OrderingComparison. lessThanOrEqualTo(T value)Creates a matcher ofComparableobject that matches when the examined object is less than or equal to the specified value, as reported by thecompareTomethod of the examined object.static Matcher<java.lang.Double>IsNaN. notANumber()Creates a matcher ofDoubles that matches when an examined double is not a number. -
Uses of Matcher in org.hamcrest.object
Classes in org.hamcrest.object that implement Matcher Modifier and Type Class Description classHasEqualValues<T>classHasToString<T>classIsCompatibleType<T>classIsEventFromTests if the value is an event announced by a specific object.Methods in org.hamcrest.object that return Matcher Modifier and Type Method Description static Matcher<java.util.EventObject>IsEventFrom. eventFrom(java.lang.Class<? extends java.util.EventObject> eventClass, java.lang.Object source)Creates a matcher ofEventObjectthat matches any object derived from eventClass announced by source.static Matcher<java.util.EventObject>IsEventFrom. eventFrom(java.lang.Object source)Creates a matcher ofEventObjectthat matches any EventObject announced by source.static <T> Matcher<T>HasToString. hasToString(java.lang.String expectedToString)Creates a matcher that matches any examined object whosetoStringmethod returns a value equalTo the specified string.static <T> Matcher<T>HasToString. hasToString(Matcher<? super java.lang.String> toStringMatcher)Creates a matcher that matches any examined object whosetoStringmethod returns a value that satisfies the specified matcher.static <T> Matcher<java.lang.Class<?>>IsCompatibleType. typeCompatibleWith(java.lang.Class<T> baseType)Creates a matcher ofClassthat matches when the specified baseType is assignable from the examined class.Methods in org.hamcrest.object with parameters of type Matcher Modifier and Type Method Description static <T> Matcher<T>HasToString. hasToString(Matcher<? super java.lang.String> toStringMatcher)Creates a matcher that matches any examined object whosetoStringmethod returns a value that satisfies the specified matcher.Constructors in org.hamcrest.object with parameters of type Matcher Constructor Description HasToString(Matcher<? super java.lang.String> toStringMatcher) -
Uses of Matcher in org.hamcrest.text
Classes in org.hamcrest.text that implement Matcher Modifier and Type Class Description classCharSequenceLengthclassIsBlankStringMatches blank Strings (and null).classIsEmptyStringMatches empty Strings (and null).classIsEqualCompressingWhiteSpaceTests if a string is equal to another string, compressing any changes in whitespace.classIsEqualIgnoringCaseTests if a string is equal to another string, regardless of the case.classMatchesPatternclassStringContainsInOrderMethods in org.hamcrest.text that return Matcher Modifier and Type Method Description static Matcher<java.lang.String>IsBlankString. blankOrNullString()Creates a matcher ofStringthat matches when the examined string isnull, or contains zero or more whitespace characters and nothing else.static Matcher<java.lang.String>IsBlankString. blankString()Creates a matcher ofStringthat matches when the examined string contains zero or more whitespace characters and nothing else.static Matcher<java.lang.String>IsEmptyString. emptyOrNullString()Creates a matcher ofStringthat matches when the examined string isnull, or has zero length.static Matcher<java.lang.String>IsEmptyString. emptyString()Creates a matcher ofStringthat matches when the examined string has zero length.static Matcher<java.lang.String>IsEqualCompressingWhiteSpace. equalToCompressingWhiteSpace(java.lang.String expectedString)Creates a matcher ofStringthat matches when the examined string is equal to the specified expectedString, when whitespace differences are (mostly) ignored.static Matcher<java.lang.String>IsEqualIgnoringCase. equalToIgnoringCase(java.lang.String expectedString)Creates a matcher ofStringthat matches when the examined string is equal to the specified expectedString, ignoring case.static Matcher<java.lang.String>IsEqualCompressingWhiteSpace. equalToIgnoringWhiteSpace(java.lang.String expectedString)static Matcher<java.lang.CharSequence>CharSequenceLength. hasLength(int length)Creates a matcher ofCharSequencethat matches when a char sequence has the given length For example:static Matcher<java.lang.CharSequence>CharSequenceLength. hasLength(Matcher<? super java.lang.Integer> lengthMatcher)Creates a matcher ofCharSequencethat matches when a char sequence has the given length For example:static Matcher<java.lang.String>IsEmptyString. isEmptyOrNullString()Deprecated.use is(emptyOrNullString()) insteadstatic Matcher<java.lang.String>IsEmptyString. isEmptyString()Deprecated.use is(emptyString()) insteadstatic Matcher<java.lang.String>MatchesPattern. matchesPattern(java.lang.String regex)Creates a matcher ofStringthat matches when the examined string exactly matches the given regular expression, treated as aPattern.static Matcher<java.lang.String>MatchesPattern. matchesPattern(java.util.regex.Pattern pattern)Creates a matcher ofStringthat matches when the examined string exactly matches the givenPattern.static Matcher<java.lang.String>StringContainsInOrder. stringContainsInOrder(java.lang.Iterable<java.lang.String> substrings)Creates a matcher ofStringthat matches when the examined string contains all of the specified substrings, considering the order of their appearance.static Matcher<java.lang.String>StringContainsInOrder. stringContainsInOrder(java.lang.String... substrings)Creates a matcher ofStringthat matches when the examined string contains all of the specified substrings, considering the order of their appearance.Methods in org.hamcrest.text with parameters of type Matcher Modifier and Type Method Description static Matcher<java.lang.CharSequence>CharSequenceLength. hasLength(Matcher<? super java.lang.Integer> lengthMatcher)Creates a matcher ofCharSequencethat matches when a char sequence has the given length For example:Constructors in org.hamcrest.text with parameters of type Matcher Constructor Description CharSequenceLength(Matcher<? super java.lang.Integer> lengthMatcher) -
Uses of Matcher in org.hamcrest.xml
Classes in org.hamcrest.xml that implement Matcher Modifier and Type Class Description classHasXPathApplies a Matcher to a given XML Node in an existing XML Node tree, specified by an XPath expression.Methods in org.hamcrest.xml that return Matcher Modifier and Type Method Description static Matcher<org.w3c.dom.Node>HasXPath. hasXPath(java.lang.String xPath)Creates a matcher ofNodes that matches when the examined node contains a node at the specifiedxPath, with any content.static Matcher<org.w3c.dom.Node>HasXPath. hasXPath(java.lang.String xPath, javax.xml.namespace.NamespaceContext namespaceContext)Creates a matcher ofNodes that matches when the examined node contains a node at the specifiedxPathwithin the specified namespace context, with any content.static Matcher<org.w3c.dom.Node>HasXPath. hasXPath(java.lang.String xPath, javax.xml.namespace.NamespaceContext namespaceContext, Matcher<java.lang.String> valueMatcher)Creates a matcher ofNodes that matches when the examined node has a value at the specifiedxPath, within the specifiednamespaceContext, that satisfies the specifiedvalueMatcher.static Matcher<org.w3c.dom.Node>HasXPath. hasXPath(java.lang.String xPath, Matcher<java.lang.String> valueMatcher)Creates a matcher ofNodes that matches when the examined node has a value at the specifiedxPaththat satisfies the specifiedvalueMatcher.Methods in org.hamcrest.xml with parameters of type Matcher Modifier and Type Method Description static Matcher<org.w3c.dom.Node>HasXPath. hasXPath(java.lang.String xPath, javax.xml.namespace.NamespaceContext namespaceContext, Matcher<java.lang.String> valueMatcher)Creates a matcher ofNodes that matches when the examined node has a value at the specifiedxPath, within the specifiednamespaceContext, that satisfies the specifiedvalueMatcher.static Matcher<org.w3c.dom.Node>HasXPath. hasXPath(java.lang.String xPath, Matcher<java.lang.String> valueMatcher)Creates a matcher ofNodes that matches when the examined node has a value at the specifiedxPaththat satisfies the specifiedvalueMatcher.Constructors in org.hamcrest.xml with parameters of type Matcher Constructor Description HasXPath(java.lang.String xPathExpression, javax.xml.namespace.NamespaceContext namespaceContext, Matcher<java.lang.String> valueMatcher)HasXPath(java.lang.String xPathExpression, Matcher<java.lang.String> valueMatcher)
-