org.hamcrest.collection
Class IsArrayWithSize<E>
java.lang.Object
org.hamcrest.BaseMatcher<T>
org.hamcrest.TypeSafeDiagnosingMatcher<T>
org.hamcrest.FeatureMatcher<E[],Integer>
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.
IsArrayWithSize
public IsArrayWithSize(Matcher<? super Integer> sizeMatcher)
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.