Package org.hamcrest.collection
Class IsIterableContainingInOrder<E>
java.lang.Object
org.hamcrest.BaseMatcher<Iterable<? extends E>>
org.hamcrest.TypeSafeDiagnosingMatcher<Iterable<? extends E>>
org.hamcrest.collection.IsIterableContainingInOrder<E>
- Type Parameters:
E
- the type of items in the iterable.
- All Implemented Interfaces:
Matcher<Iterable<? extends E>>
,SelfDescribing
public class IsIterableContainingInOrder<E>
extends TypeSafeDiagnosingMatcher<Iterable<? extends E>>
Tests if an iterable contains matching elements in order.
-
Constructor Summary
ConstructorDescriptionIsIterableContainingInOrder
(List<Matcher<? super E>> matchers) Constructor, best called from one of the static "contains
" factory methods. -
Method Summary
Modifier and TypeMethodDescriptioncontains
(E... items) void
describeTo
(Description description) Generates a description of the object.protected boolean
matchesSafely
(Iterable<? extends E> iterable, Description mismatchDescription) Subclasses should implement this.Methods inherited from class org.hamcrest.TypeSafeDiagnosingMatcher
describeMismatch, matches
Methods inherited from class org.hamcrest.BaseMatcher
_dont_implement_Matcher___instead_extend_BaseMatcher_, isNotNull, toString
-
Constructor Details
-
IsIterableContainingInOrder
Constructor, best called from one of the static "contains
" factory methods.- Parameters:
matchers
- the matchers- See Also:
-
-
Method Details
-
matchesSafely
Description copied from class:TypeSafeDiagnosingMatcher
Subclasses should implement this. The item will already have been checked for the specific type and will never be null.- Specified by:
matchesSafely
in classTypeSafeDiagnosingMatcher<Iterable<? extends E>>
- Parameters:
iterable
- the item.mismatchDescription
- the mismatch description.- Returns:
- boolean true/false depending if item matches matcher.
-
describeTo
Description copied from interface:SelfDescribing
Generates a description of the object. The description may be part of a description of a larger object of which this is just a component, so it should be worded appropriately.- Parameters:
description
- The description to be built or appended to.
-
contains
Creates a matcher forIterable
s that matches when a single pass over the examinedIterable
yields a series of items, each logically equal to the corresponding item in the specified items. For a positive match, the examined iterable must be of the same length as the number of specified items. For example:assertThat(Arrays.asList("foo", "bar"), contains("foo", "bar"))
- Type Parameters:
E
- the matcher type.- Parameters:
items
- the items that must equal the items provided by an examinedIterable
- Returns:
- The matcher.
-
contains
Creates a matcher forIterable
s that matches when a single pass over the examinedIterable
yields a single item that satisfies the specified matcher. For a positive match, the examined iterable must only yield one item. For example:assertThat(Arrays.asList("foo"), contains(equalTo("foo")))
- Type Parameters:
E
- the matcher type.- Parameters:
itemMatcher
- the matcher that must be satisfied by the single item provided by an examinedIterable
- Returns:
- The matcher.
-
contains
@SafeVarargs public static <E> Matcher<Iterable<? extends E>> contains(Matcher<? super E>... itemMatchers) Creates a matcher forIterable
s that matches when a single pass over the examinedIterable
yields a series of items, each satisfying the corresponding matcher in the specified matchers. For a positive match, the examined iterable must be of the same length as the number of specified matchers. For example:assertThat(Arrays.asList("foo", "bar"), contains(equalTo("foo"), equalTo("bar")))
- Type Parameters:
E
- the matcher type.- Parameters:
itemMatchers
- the matchers that must be satisfied by the items provided by an examinedIterable
- Returns:
- The matcher.
-
contains
Creates a matcher forIterable
s that matches when a single pass over the examinedIterable
yields a series of items, each satisfying the corresponding matcher in the specified list of matchers. For a positive match, the examined iterable must be of the same length as the specified list of matchers. For example:assertThat(Arrays.asList("foo", "bar"), contains(Arrays.asList(equalTo("foo"), equalTo("bar"))))
- Type Parameters:
E
- the matcher type.- Parameters:
itemMatchers
- a list of matchers, each of which must be satisfied by the corresponding item provided by an examinedIterable
- Returns:
- The matcher.
-