org.hamcrest.collection
Class IsCollectionWithSize<E>

java.lang.Object
  extended by org.hamcrest.BaseMatcher<T>
      extended by org.hamcrest.TypeSafeDiagnosingMatcher<T>
          extended by org.hamcrest.FeatureMatcher<Collection<? extends E>,Integer>
              extended by 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.


Constructor Summary
IsCollectionWithSize(Matcher<? super Integer> sizeMatcher)
           
 
Method Summary
protected  Integer featureValueOf(Collection<? extends E> actual)
          Implement this to extract the interesting feature.
static
<E> Matcher<Collection<? extends E>>
hasSize(int size)
          This is a shortcut to the frequently used hasSize(equalTo(x)).
static
<E> Matcher<Collection<? extends E>>
hasSize(Matcher<? super Integer> size)
          Does collection size satisfy a given 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IsCollectionWithSize

public IsCollectionWithSize(Matcher<? super Integer> sizeMatcher)
Method Detail

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))