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
ConstructorsConstructorDescriptionIsIterableWithSize(Matcher<? super Integer> sizeMatcher) Constructor, best called fromiterableWithSize(int)oriterableWithSize(Matcher). -
Method Summary
Modifier and TypeMethodDescriptionprotected IntegerfeatureValueOf(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, matchesSafelyMethods inherited from class org.hamcrest.TypeSafeDiagnosingMatcher
describeMismatch, matchesMethods 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:FeatureMatcherImplement this to extract the interesting feature.- Specified by:
featureValueOfin classFeatureMatcher<Iterable<E>,Integer> - Parameters:
actual- the target object- Returns:
- the feature to be matched
-
iterableWithSize
Creates a matcher forIterables that matches when a single pass over the examinedIterableyields 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 forIterables that matches when a single pass over the examinedIterableyields an item count that is equal to the specifiedsizeargument. 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.
-