Top Inners Fields Constructors Methods
org.hamcrest.collection

public Class IsIterableContainingInAnyOrder<T>

extends TypeSafeDiagnosingMatcher<Iterable<? extends T>>
Class Inheritance
Imports
org.hamcrest.Description, .Factory, .Matcher, .TypeSafeDiagnosingMatcher, java.util.ArrayList, .Arrays, .Collection, .List

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final Collection<Matcher<? super T>>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static <E> Matcher<Iterable<? extends E>>
containsInAnyOrder(final Matcher<? super E>
the matcher that must be satisfied by the single item provided by an examined Iterable
itemMatcher
)

Deprecated use contains(Matcher itemMatcher) instead
Creates a matcher for Iterables that matches when a single pass over the examined Iterable yields a single item that satisfies the specified matcher.
public static <T> Matcher<Iterable<? extends T>>
containsInAnyOrder(Matcher<? super T>...
a list of matchers, each of which must be satisfied by an item provided by an examined Iterable
itemMatchers
)

Creates an order agnostic matcher for Iterables that matches when a single pass over the examined Iterable yields a series of items, each satisfying one matcher anywhere in the specified matchers.

public static <T> Matcher<Iterable<? extends T>>
containsInAnyOrder(T...
the items that must equal the items provided by an examined Iterable in any order
items
)

Creates an order agnostic matcher for Iterables that matches when a single pass over the examined Iterable yields a series of items, each logically equal to one item anywhere in the specified items.

public static <T> Matcher<Iterable<? extends T>>
containsInAnyOrder(Collection<Matcher<? super T>>
a list of matchers, each of which must be satisfied by an item provided by an examined Iterable
itemMatchers
)

Creates an order agnostic matcher for Iterables that matches when a single pass over the examined Iterable yields a series of items, each satisfying one matcher anywhere in the specified collection of matchers.

public void
describeTo(Description
The description to be built or appended to.
description
)

Implements org.hamcrest.SelfDescribing.describeTo.

Generates a description of the object.
protected boolean
matchesSafely(Iterable<? extends T> items, Description mismatchDescription)

Implements abstract org.hamcrest.TypeSafeDiagnosingMatcher.matchesSafely.

Subclasses should implement this.
Inherited from org.hamcrest.TypeSafeDiagnosingMatcher:
describeMismatchmatches

Field Detail

matchersback to summary
private final Collection<Matcher<? super T>> matchers

Constructor Detail

IsIterableContainingInAnyOrderback to summary
public IsIterableContainingInAnyOrder(Collection<Matcher<? super T>> matchers)

Method Detail

containsInAnyOrderback to summary
public static <E> Matcher<Iterable<? extends E>> containsInAnyOrder(final Matcher<? super E> itemMatcher)

Deprecated

use contains(Matcher itemMatcher) instead

Creates a matcher for Iterables that matches when a single pass over the examined Iterable 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"), containsInAnyOrder(equalTo("foo")))
Parameters
itemMatcher:Matcher<? super E>

the matcher that must be satisfied by the single item provided by an examined Iterable

Annotations
@SuppressWarnings:unchecked
@Deprecated
@Factory
containsInAnyOrderback to summary
public static <T> Matcher<Iterable<? extends T>> containsInAnyOrder(Matcher<? super T>... itemMatchers)

Creates an order agnostic matcher for Iterables that matches when a single pass over the examined Iterable yields a series of items, each satisfying one matcher anywhere in the specified matchers. For a positive match, the examined iterable must be of the same length as the number of specified matchers.

N.B. each of the specified matchers will only be used once during a given examination, so be careful when specifying matchers that may be satisfied by more than one entry in an examined iterable.

For example:

assertThat(Arrays.asList("foo", "bar"), containsInAnyOrder(equalTo("bar"), equalTo("foo")))
Parameters
itemMatchers:Matcher<? super T>[]

a list of matchers, each of which must be satisfied by an item provided by an examined Iterable

Annotations
@Factory
containsInAnyOrderback to summary
public static <T> Matcher<Iterable<? extends T>> containsInAnyOrder(T... items)

Creates an order agnostic matcher for Iterables that matches when a single pass over the examined Iterable yields a series of items, each logically equal to one item anywhere in the specified items. For a positive match, the examined iterable must be of the same length as the number of specified items.

N.B. each of the specified items will only be used once during a given examination, so be careful when specifying items that may be equal to more than one entry in an examined iterable.

For example:

assertThat(Arrays.asList("foo", "bar"), containsInAnyOrder("bar", "foo"))
Parameters
items:T[]

the items that must equal the items provided by an examined Iterable in any order

Annotations
@Factory
containsInAnyOrderback to summary
public static <T> Matcher<Iterable<? extends T>> containsInAnyOrder(Collection<Matcher<? super T>> itemMatchers)

Creates an order agnostic matcher for Iterables that matches when a single pass over the examined Iterable yields a series of items, each satisfying one matcher anywhere in the specified collection of matchers. For a positive match, the examined iterable must be of the same length as the specified collection of matchers.

N.B. each matcher in the specified collection will only be used once during a given examination, so be careful when specifying matchers that may be satisfied by more than one entry in an examined iterable.

For example:

assertThat(Arrays.asList("foo", "bar"), containsInAnyOrder(Arrays.asList(equalTo("bar"), equalTo("foo"))))
Parameters
itemMatchers:Collection<Matcher<? super T>>

a list of matchers, each of which must be satisfied by an item provided by an examined Iterable

Annotations
@Factory
describeToback to summary
public void describeTo(Description description)

Implements org.hamcrest.SelfDescribing.describeTo.

Doc from org.hamcrest.SelfDescribing.describeTo.

Generates a description of the object. The description may be part of a a description of a larger object of which this is just a component, so it should be worded appropriately.

Parameters
description:Description

The description to be built or appended to.

Annotations
@Override
matchesSafelyback to summary
protected boolean matchesSafely(Iterable<? extends T> items, Description mismatchDescription)

Implements abstract org.hamcrest.TypeSafeDiagnosingMatcher.matchesSafely.

Doc from org.hamcrest.TypeSafeDiagnosingMatcher.matchesSafely.

Subclasses should implement this. The item will already have been checked for the specific type and will never be null.

Annotations
@Override
org.hamcrest.collection back to summary

private Class IsIterableContainingInAnyOrder.Matching<S>

extends Object
Class Inheritance
  • java.lang.Object
  • org.hamcrest.collection.IsIterableContainingInAnyOrder.Matching

Field Summary

Modifier and TypeField and Description
private final Collection<Matcher<? super S>>
private final Description

Constructor Summary

AccessConstructor and Description
public
Matching(Collection<Matcher<? super S>> matchers, Description mismatchDescription)

Method Summary

Modifier and TypeMethod and Description
public boolean
isFinished(Iterable<? extends S> items)

private boolean
isMatched(S item)

private boolean
isNotSurplus(S item)

public boolean
matches(S item)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

matchersback to summary
private final Collection<Matcher<? super S>> matchers
mismatchDescriptionback to summary
private final Description mismatchDescription

Constructor Detail

Matchingback to summary
public Matching(Collection<Matcher<? super S>> matchers, Description mismatchDescription)

Method Detail

isFinishedback to summary
public boolean isFinished(Iterable<? extends S> items)
isMatchedback to summary
private boolean isMatched(S item)
isNotSurplusback to summary
private boolean isNotSurplus(S item)
matchesback to summary
public boolean matches(S item)