Top Description Constructors Methods
org.hamcrest.collection

public Class IsCollectionWithSize<E>

extends FeatureMatcher<Collection<? extends E>, Integer>
Class Inheritance
Imports
org.hamcrest.Factory, .FeatureMatcher, .Matcher, java.util.Collection

Matches if collection size satisfies a nested matcher.

Constructor Summary

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

Method Summary

Modifier and TypeMethod and Description
protected Integer
featureValueOf(Collection<? extends E>
the target object
actual
)

Implements abstract org.hamcrest.FeatureMatcher.featureValueOf.

Implement this to extract the interesting feature.
public static <E> Matcher<Collection<? extends E>>
hasSize(Matcher<? super Integer>
a matcher for the size of an examined java.util.Collection
sizeMatcher
)

Creates a matcher for java.util.Collections that matches when the size() method returns a value that satisfies the specified matcher.

public static <E> Matcher<Collection<? extends E>>
hasSize(int
the expected size of an examined java.util.Collection
size
)

Creates a matcher for java.util.Collections that matches when the size() method returns a value equal to the specified size.

Inherited from org.hamcrest.FeatureMatcher:
describeTomatchesSafely

Constructor Detail

IsCollectionWithSizeback to summary
public IsCollectionWithSize(Matcher<? super Integer> sizeMatcher)

Method Detail

featureValueOfback to summary
protected Integer featureValueOf(Collection<? extends E> actual)

Implements abstract org.hamcrest.FeatureMatcher.featureValueOf.

Doc from org.hamcrest.FeatureMatcher.featureValueOf.

Implement this to extract the interesting feature.

Parameters
actual:Collection<? extends E>

the target object

Returns:Integer

the feature to be matched

Annotations
@Override
hasSizeback to summary
public static <E> Matcher<Collection<? extends E>> hasSize(Matcher<? super Integer> sizeMatcher)

Creates a matcher for java.util.Collections that matches when the size() method returns a value that satisfies the specified matcher.

For example:

assertThat(Arrays.asList("foo", "bar"), hasSize(equalTo(2)))
Parameters
sizeMatcher:Matcher<? super Integer>

a matcher for the size of an examined java.util.Collection

Annotations
@Factory
hasSizeback to summary
public static <E> Matcher<Collection<? extends E>> hasSize(int size)

Creates a matcher for java.util.Collections that matches when the size() method returns a value equal to the specified size.

For example:

assertThat(Arrays.asList("foo", "bar"), hasSize(2))
Parameters
size:int

the expected size of an examined java.util.Collection

Annotations
@Factory