Top Description Fields Constructors Methods
org.hamcrest.collection

public Class IsArray<T>

extends TypeSafeMatcher<T[]>
Class Inheritance
Imports
org.hamcrest.Description, .Matcher, .TypeSafeMatcher, java.util.Arrays

Matcher for array whose elements satisfy a sequence of matchers. The array size must equal the number of element matchers.

Field Summary

Modifier and TypeField and Description
private final Matcher<? super T>[]

Constructor Summary

AccessConstructor and Description
public
IsArray(Matcher<? super T>[] elementMatchers)

Method Summary

Modifier and TypeMethod and Description
public static <T> IsArray<T>
array(Matcher<? super T>...
the matchers that the elements of examined arrays should satisfy
elementMatchers
)

Creates a matcher that matches arrays whose elements are satisfied by the specified matchers.

public void
describeMismatchSafely(T[] actual, Description mismatchDescription)

Overrides org.hamcrest.TypeSafeMatcher.describeMismatchSafely.

Subclasses should override this.
public void
describeTo(Description
The description to be built or appended to.
description
)

Implements org.hamcrest.SelfDescribing.describeTo.

Generates a description of the object.
protected String
descriptionEnd()

Returns the string that ends the description.

protected String
descriptionSeparator()

Returns the string that separates the elements in the description.

protected String
descriptionStart()

Returns the string that starts the description.

public boolean
matchesSafely(T[] array)

Implements abstract org.hamcrest.TypeSafeMatcher.matchesSafely.

Subclasses should implement this.
Inherited from org.hamcrest.TypeSafeMatcher:
describeMismatchmatches

Field Detail

elementMatchersback to summary
private final Matcher<? super T>[] elementMatchers

Constructor Detail

IsArrayback to summary
public IsArray(Matcher<? super T>[] elementMatchers)

Method Detail

arrayback to summary
public static <T> IsArray<T> array(Matcher<? super T>... elementMatchers)

Creates a matcher that matches arrays whose elements are satisfied by the specified matchers. Matches positively only if the number of matchers specified is equal to the length of the examined array and each matcher[i] is satisfied by array[i]. For example:

assertThat(new Integer[]{1,2,3}, is(array(equalTo(1), equalTo(2), equalTo(3))))
Parameters
elementMatchers:Matcher<? super T>[]

the matchers that the elements of examined arrays should satisfy

describeMismatchSafelyback to summary
public void describeMismatchSafely(T[] actual, Description mismatchDescription)

Overrides org.hamcrest.TypeSafeMatcher.describeMismatchSafely.

Doc from org.hamcrest.TypeSafeMatcher.describeMismatchSafely.

Subclasses should override this. The item will already have been checked for the specific type and will never be null.

Annotations
@Override
describeToback to summary
public void describeTo(Description description)

Implements org.hamcrest.SelfDescribing.describeTo.

Doc from org.hamcrest.SelfDescribing.describeTo.

Generates a description of the object. The description may be part of a a description of a larger object of which this is just a component, so it should be worded appropriately.

Parameters
description:Description

The description to be built or appended to.

Annotations
@Override
@SuppressWarnings:unchecked
descriptionEndback to summary
protected String descriptionEnd()

Returns the string that ends the description. Can be overridden in subclasses to customise how the matcher is described.

descriptionSeparatorback to summary
protected String descriptionSeparator()

Returns the string that separates the elements in the description. Can be overridden in subclasses to customise how the matcher is described.

descriptionStartback to summary
protected String descriptionStart()

Returns the string that starts the description. Can be overridden in subclasses to customise how the matcher is described.

matchesSafelyback to summary
public boolean matchesSafely(T[] array)

Implements abstract org.hamcrest.TypeSafeMatcher.matchesSafely.

Doc from org.hamcrest.TypeSafeMatcher.matchesSafely.

Subclasses should implement this. The item will already have been checked for the specific type and will never be null.

Annotations
@Override