Package org.hamcrest.collection
Class IsIterableWithSize<E>
- java.lang.Object
-
- org.hamcrest.BaseMatcher<T>
-
- org.hamcrest.TypeSafeDiagnosingMatcher<T>
-
- org.hamcrest.FeatureMatcher<java.lang.Iterable<E>,java.lang.Integer>
-
- org.hamcrest.collection.IsIterableWithSize<E>
-
- All Implemented Interfaces:
Matcher<java.lang.Iterable<E>>
,SelfDescribing
public class IsIterableWithSize<E> extends FeatureMatcher<java.lang.Iterable<E>,java.lang.Integer>
-
-
Constructor Summary
Constructors Constructor Description IsIterableWithSize(Matcher<? super java.lang.Integer> sizeMatcher)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.Integer
featureValueOf(java.lang.Iterable<E> actual)
Implement this to extract the interesting feature.static <E> Matcher<java.lang.Iterable<E>>
iterableWithSize(int size)
Creates a matcher forIterable
s that matches when a single pass over the examinedIterable
yields an item count that is equal to the specifiedsize
argument.static <E> Matcher<java.lang.Iterable<E>>
iterableWithSize(Matcher<? super java.lang.Integer> sizeMatcher)
Creates a matcher forIterable
s that matches when a single pass over the examinedIterable
yields an item count that satisfies the specified matcher.-
Methods inherited from class org.hamcrest.FeatureMatcher
describeTo, matchesSafely
-
Methods inherited from class org.hamcrest.TypeSafeDiagnosingMatcher
describeMismatch, matches
-
Methods inherited from class org.hamcrest.BaseMatcher
_dont_implement_Matcher___instead_extend_BaseMatcher_, toString
-
-
-
-
Constructor Detail
-
IsIterableWithSize
public IsIterableWithSize(Matcher<? super java.lang.Integer> sizeMatcher)
-
-
Method Detail
-
featureValueOf
protected java.lang.Integer featureValueOf(java.lang.Iterable<E> actual)
Description copied from class:FeatureMatcher
Implement this to extract the interesting feature.- Specified by:
featureValueOf
in classFeatureMatcher<java.lang.Iterable<E>,java.lang.Integer>
- Parameters:
actual
- the target object- Returns:
- the feature to be matched
-
iterableWithSize
public static <E> Matcher<java.lang.Iterable<E>> iterableWithSize(Matcher<? super java.lang.Integer> sizeMatcher)
Creates a matcher forIterable
s that matches when a single pass over the examinedIterable
yields an item count that satisfies the specified matcher. For example:assertThat(Arrays.asList("foo", "bar"), iterableWithSize(equalTo(2)))
- Parameters:
sizeMatcher
- a matcher for the number of items that should be yielded by an examinedIterable
-
iterableWithSize
public static <E> Matcher<java.lang.Iterable<E>> iterableWithSize(int size)
Creates a matcher forIterable
s that matches when a single pass over the examinedIterable
yields an item count that is equal to the specifiedsize
argument. For example:assertThat(Arrays.asList("foo", "bar"), iterableWithSize(2))
- Parameters:
size
- the number of items that should be yielded by an examinedIterable
-
-