org.hamcrest.collection
Class IsCollectionWithSize<E>
java.lang.Object
org.hamcrest.BaseMatcher<T>
org.hamcrest.TypeSafeDiagnosingMatcher<T>
org.hamcrest.FeatureMatcher<Collection<? extends E>,Integer>
org.hamcrest.collection.IsCollectionWithSize<E>
- All Implemented Interfaces:
- Matcher<Collection<? extends E>>, SelfDescribing
public class IsCollectionWithSize<E>
- extends FeatureMatcher<Collection<? extends E>,Integer>
Matches if collection size satisfies a nested matcher.
Method Summary |
protected Integer |
featureValueOf(Collection<? extends E> actual)
Implement this to extract the interesting feature. |
static
|
hasSize(int size)
This is a shortcut to the frequently used hasSize(equalTo(x)). |
static
|
hasSize(Matcher<? super Integer> size)
Does collection size satisfy a given matcher? |
IsCollectionWithSize
public IsCollectionWithSize(Matcher<? super Integer> sizeMatcher)
featureValueOf
protected Integer featureValueOf(Collection<? extends E> actual)
- Description copied from class:
FeatureMatcher
- Implement this to extract the interesting feature.
- Specified by:
featureValueOf
in class FeatureMatcher<Collection<? extends E>,Integer>
- Parameters:
actual
- the target object
- Returns:
- the feature to be matched
hasSize
public static <E> Matcher<Collection<? extends E>> hasSize(Matcher<? super Integer> size)
- Does collection size satisfy a given matcher?
hasSize
public static <E> Matcher<Collection<? extends E>> hasSize(int size)
- This is a shortcut to the frequently used hasSize(equalTo(x)).
For example, assertThat(hasSize(equal_to(x)))
vs. assertThat(hasSize(x))