Package org.hamcrest.collection
Class IsIterableWithSize<E>
java.lang.Object
- Type Parameters:
E
- the iterable element type
- All Implemented Interfaces:
Matcher<Iterable<E>>
,SelfDescribing
Matches if iterable size satisfies a size matcher.
-
Constructor Summary
ConstructorDescriptionIsIterableWithSize
(Matcher<? super Integer> sizeMatcher) Constructor, best called fromiterableWithSize(int)
oriterableWithSize(Matcher)
. -
Method Summary
Modifier and TypeMethodDescriptionprotected Integer
featureValueOf
(Iterable<E> actual) Implement this to extract the interesting feature.iterableWithSize
(int size) iterableWithSize
(Matcher<? super Integer> sizeMatcher) 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_, isNotNull, toString
-
Constructor Details
-
IsIterableWithSize
Constructor, best called fromiterableWithSize(int)
oriterableWithSize(Matcher)
.- Parameters:
sizeMatcher
- checks the expected size of the iterable
-
-
Method Details
-
featureValueOf
Description copied from class:FeatureMatcher
Implement this to extract the interesting feature.- Specified by:
featureValueOf
in classFeatureMatcher<Iterable<E>,
Integer> - Parameters:
actual
- the target object- Returns:
- the feature to be matched
-
iterableWithSize
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)))
- Type Parameters:
E
- the matcher type.- Parameters:
sizeMatcher
- a matcher for the number of items that should be yielded by an examinedIterable
- Returns:
- The matcher.
-
iterableWithSize
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))
- Type Parameters:
E
- the matcher type.- Parameters:
size
- the number of items that should be yielded by an examinedIterable
- Returns:
- The matcher.
-