org.hamcrest.collection
Class IsArrayWithSize<E>

java.lang.Object
  extended by org.hamcrest.BaseMatcher<T>
      extended by org.hamcrest.TypeSafeDiagnosingMatcher<T>
          extended by org.hamcrest.FeatureMatcher<E[],Integer>
              extended by org.hamcrest.collection.IsArrayWithSize<E>
All Implemented Interfaces:
Matcher<E[]>, SelfDescribing

public class IsArrayWithSize<E>
extends FeatureMatcher<E[],Integer>

Matches if array size satisfies a nested matcher.


Constructor Summary
IsArrayWithSize(Matcher<? super Integer> sizeMatcher)
           
 
Method Summary
static
<E> Matcher<E[]>
arrayWithSize(int size)
          This is a shortcut to the frequently used arrayWithSize(equalTo(x)).
static
<E> Matcher<E[]>
arrayWithSize(Matcher<? super Integer> sizeMatcher)
          Does array size satisfy a given matcher?
static
<E> Matcher<E[]>
emptyArray()
          Matches an empty array.
protected  Integer featureValueOf(E[] actual)
          Implement this to extract the interesting feature.
 
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

IsArrayWithSize

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

featureValueOf

protected Integer featureValueOf(E[] actual)
Description copied from class: FeatureMatcher
Implement this to extract the interesting feature.

Specified by:
featureValueOf in class FeatureMatcher<E[],Integer>
Parameters:
actual - the target object
Returns:
the feature to be matched

arrayWithSize

public static <E> Matcher<E[]> arrayWithSize(Matcher<? super Integer> sizeMatcher)
Does array size satisfy a given matcher?


arrayWithSize

public static <E> Matcher<E[]> arrayWithSize(int size)
This is a shortcut to the frequently used arrayWithSize(equalTo(x)). For example, assertThat(arrayWithSize(equal_to(x))) vs. assertThat(arrayWithSize(x))


emptyArray

public static <E> Matcher<E[]> emptyArray()
Matches an empty array.