Top Description Constructors Methods
org.hamcrest.collection

public Class IsArrayWithSize<E>

extends FeatureMatcher<E[], Integer>
Class Inheritance
Imports
org.hamcrest.Factory, .FeatureMatcher, .Matcher

Matches if array size satisfies a nested matcher.

Constructor Summary

AccessConstructor and Description
public
IsArrayWithSize(Matcher<? super Integer> sizeMatcher)

Method Summary

Modifier and TypeMethod and Description
public static <E> Matcher<E[]>
arrayWithSize(Matcher<? super Integer>
a matcher for the length of an examined array
sizeMatcher
)

Creates a matcher for arrays that matches when the length of the array satisfies the specified matcher.

public static <E> Matcher<E[]>
arrayWithSize(int
the length that an examined array must have for a positive match
size
)

Creates a matcher for arrays that matches when the length of the array equals the specified size.

public static <E> Matcher<E[]>
emptyArray()

Creates a matcher for arrays that matches when the length of the array is zero.

protected Integer
featureValueOf(E[]
the target object
actual
)

Implements abstract org.hamcrest.FeatureMatcher.featureValueOf.

Implement this to extract the interesting feature.
Inherited from org.hamcrest.FeatureMatcher:
describeTomatchesSafely

Constructor Detail

IsArrayWithSizeback to summary
public IsArrayWithSize(Matcher<? super Integer> sizeMatcher)

Method Detail

arrayWithSizeback to summary
public static <E> Matcher<E[]> arrayWithSize(Matcher<? super Integer> sizeMatcher)

Creates a matcher for arrays that matches when the length of the array satisfies the specified matcher.

For example:

assertThat(new String[]{"foo", "bar"}, arrayWithSize(equalTo(2)))
Parameters
sizeMatcher:Matcher<? super Integer>

a matcher for the length of an examined array

Annotations
@Factory
arrayWithSizeback to summary
public static <E> Matcher<E[]> arrayWithSize(int size)

Creates a matcher for arrays that matches when the length of the array equals the specified size.

For example:

assertThat(new String[]{"foo", "bar"}, arrayWithSize(2))
Parameters
size:int

the length that an examined array must have for a positive match

Annotations
@Factory
emptyArrayback to summary
public static <E> Matcher<E[]> emptyArray()

Creates a matcher for arrays that matches when the length of the array is zero.

For example:

assertThat(new String[0], emptyArray())
Annotations
@Factory
featureValueOfback to summary
protected Integer featureValueOf(E[] actual)

Implements abstract org.hamcrest.FeatureMatcher.featureValueOf.

Doc from org.hamcrest.FeatureMatcher.featureValueOf.

Implement this to extract the interesting feature.

Parameters
actual:E[]

the target object

Returns:Integer

the feature to be matched

Annotations
@Override