Top Constructors Methods
org.hamcrest.collection

public Class IsIterableWithSize<E>

extends FeatureMatcher<Iterable<E>, Integer>
Class Inheritance
Imports
org.hamcrest.FeatureMatcher, .Matcher, java.util.Iterator

Constructor Summary

AccessConstructor and Description
public
IsIterableWithSize(Matcher<? super Integer> sizeMatcher)

Method Summary

Modifier and TypeMethod and Description
protected Integer
featureValueOf(Iterable<E>
the target object
actual
)

Implements abstract org.hamcrest.FeatureMatcher.featureValueOf.

Implement this to extract the interesting feature.
public static <E> Matcher<Iterable<E>>
iterableWithSize(Matcher<? super Integer>
a matcher for the number of items that should be yielded by an examined Iterable
sizeMatcher
)

Creates a matcher for Iterables that matches when a single pass over the examined Iterable yields an item count that satisfies the specified matcher.

public static <E> Matcher<Iterable<E>>
iterableWithSize(int
the number of items that should be yielded by an examined Iterable
size
)

Creates a matcher for Iterables that matches when a single pass over the examined Iterable yields an item count that is equal to the specified size argument.

Inherited from org.hamcrest.FeatureMatcher:
describeTomatchesSafely

Constructor Detail

IsIterableWithSizeback to summary
public IsIterableWithSize(Matcher<? super Integer> sizeMatcher)

Method Detail

featureValueOfback to summary
protected Integer featureValueOf(Iterable<E> actual)

Implements abstract org.hamcrest.FeatureMatcher.featureValueOf.

Doc from org.hamcrest.FeatureMatcher.featureValueOf.

Implement this to extract the interesting feature.

Parameters
actual:Iterable<E>

the target object

Returns:Integer

the feature to be matched

Annotations
@Override
iterableWithSizeback to summary
public static <E> Matcher<Iterable<E>> iterableWithSize(Matcher<? super Integer> sizeMatcher)

Creates a matcher for Iterables that matches when a single pass over the examined Iterable yields an item count that satisfies the specified matcher. For example:

assertThat(Arrays.asList("foo", "bar"), iterableWithSize(equalTo(2)))
Parameters
sizeMatcher:Matcher<? super Integer>

a matcher for the number of items that should be yielded by an examined Iterable

iterableWithSizeback to summary
public static <E> Matcher<Iterable<E>> iterableWithSize(int size)

Creates a matcher for Iterables that matches when a single pass over the examined Iterable yields an item count that is equal to the specified size argument. For example:

assertThat(Arrays.asList("foo", "bar"), iterableWithSize(2))
Parameters
size:int

the number of items that should be yielded by an examined Iterable