Top Fields Constructors Methods
org.hamcrest.core

public Class IsCollectionContaining<T>

extends TypeSafeDiagnosingMatcher<Iterable<? super T>>
Class Inheritance
Annotations
@Deprecated
Imports
org.hamcrest.Description, .Matcher, .TypeSafeDiagnosingMatcher

Deprecated

As of release 2.1, replaced by IsIterableContaining.

Field Summary

Modifier and TypeField and Description
private final IsIterableContaining<T>

Constructor Summary

AccessConstructor and Description
public
IsCollectionContaining(Matcher<? super T> elementMatcher)

Method Summary

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

Implements org.hamcrest.SelfDescribing.describeTo.

Generates a description of the object.
public static <T> Matcher<Iterable<? super T>>
hasItem(Matcher<? super T>
the matcher to apply to items provided by the examined Iterable
itemMatcher
)

Deprecated As of version 2.1, use IsIterableContaining#hasItem(Matcher).
Creates a matcher for Iterables that only matches when a single pass over the examined Iterable yields at least one item that is matched by the specified itemMatcher.
public static <T> Matcher<Iterable<? super T>>
hasItem(T
the item to compare against the items provided by the examined Iterable
item
)

Deprecated As of version 2.1, use IsIterableContaining#hasItem(Object).
Creates a matcher for Iterables that only matches when a single pass over the examined Iterable yields at least one item that is equal to the specified item.
public static <T> Matcher<Iterable<T>>
hasItems(Matcher<? super T>...
the matchers to apply to items provided by the examined Iterable
itemMatchers
)

Deprecated As of version 2.1, use IsIterableContaining#hasItems(Matcher[])}.
Creates a matcher for Iterables that matches when consecutive passes over the examined Iterable yield at least one item that is matched by the corresponding matcher from the specified itemMatchers.
public static <T> Matcher<Iterable<T>>
hasItems(T...
the items to compare against the items provided by the examined Iterable
items
)

Deprecated As of version 2.1, use IsIterableContaining#hasItems(Object[])}.
Creates a matcher for Iterables that matches when consecutive passes over the examined Iterable yield at least one item that is equal to the corresponding item from the specified items.
protected boolean
matchesSafely(Iterable<? super T> collection, Description mismatchDescription)

Implements abstract org.hamcrest.TypeSafeDiagnosingMatcher.matchesSafely.

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

Field Detail

delegateback to summary
private final IsIterableContaining<T> delegate

Constructor Detail

IsCollectionContainingback to summary
public IsCollectionContaining(Matcher<? super T> elementMatcher)

Method Detail

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
hasItemback to summary
public static <T> Matcher<Iterable<? super T>> hasItem(Matcher<? super T> itemMatcher)

Deprecated

As of version 2.1, use IsIterableContaining#hasItem(Matcher).

Creates a matcher for Iterables that only matches when a single pass over the examined Iterable yields at least one item that is matched by the specified itemMatcher. Whilst matching, the traversal of the examined Iterable will stop as soon as a matching item is found. For example:

assertThat(Arrays.asList("foo", "bar"), hasItem(startsWith("ba")))
Parameters
itemMatcher:Matcher<? super T>

the matcher to apply to items provided by the examined Iterable

hasItemback to summary
public static <T> Matcher<Iterable<? super T>> hasItem(T item)

Deprecated

As of version 2.1, use IsIterableContaining#hasItem(Object).

Creates a matcher for Iterables that only matches when a single pass over the examined Iterable yields at least one item that is equal to the specified item. Whilst matching, the traversal of the examined Iterable will stop as soon as a matching item is found. For example:

assertThat(Arrays.asList("foo", "bar"), hasItem("bar"))
Parameters
item:T

the item to compare against the items provided by the examined Iterable

hasItemsback to summary
public static <T> Matcher<Iterable<T>> hasItems(Matcher<? super T>... itemMatchers)

Deprecated

As of version 2.1, use IsIterableContaining#hasItems(Matcher[])}.

Creates a matcher for Iterables that matches when consecutive passes over the examined Iterable yield at least one item that is matched by the corresponding matcher from the specified itemMatchers. Whilst matching, each traversal of the examined Iterable will stop as soon as a matching item is found. For example:

assertThat(Arrays.asList("foo", "bar", "baz"), hasItems(endsWith("z"), endsWith("o")))
Parameters
itemMatchers:Matcher<? super T>[]

the matchers to apply to items provided by the examined Iterable

Annotations
@SafeVarargs
hasItemsback to summary
public static <T> Matcher<Iterable<T>> hasItems(T... items)

Deprecated

As of version 2.1, use IsIterableContaining#hasItems(Object[])}.

Creates a matcher for Iterables that matches when consecutive passes over the examined Iterable yield at least one item that is equal to the corresponding item from the specified items. Whilst matching, each traversal of the examined Iterable will stop as soon as a matching item is found. For example:

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

the items to compare against the items provided by the examined Iterable

Annotations
@SafeVarargs
matchesSafelyback to summary
protected boolean matchesSafely(Iterable<? super T> collection, 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