Top Description Constructors Methods
org.hamcrest.collection

public final Class IsMapWithSize<K, V>

extends FeatureMatcher<Map<? extends K, ? extends V>, Integer>
Class Inheritance
Imports
org.hamcrest.FeatureMatcher, .Matcher, java.util.Map

Matches if map size satisfies a nested matcher.

Constructor Summary

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

Method Summary

Modifier and TypeMethod and Description
public static <K, V> Matcher<Map<? extends K, ? extends V>>
aMapWithSize(Matcher<? super Integer>
a matcher for the size of an examined java.util.Map
sizeMatcher
)

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

public static <K, V> Matcher<Map<? extends K, ? extends V>>
aMapWithSize(int
the expected size of an examined java.util.Map
size
)

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

public static <K, V> Matcher<Map<? extends K, ? extends V>>
anEmptyMap()

Creates a matcher for java.util.Maps that matches when the size() method returns zero.

protected Integer
featureValueOf(Map<? extends K, ? extends V>
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

IsMapWithSizeback to summary
public IsMapWithSize(Matcher<? super Integer> sizeMatcher)
Annotations
@SuppressWarnings:WeakerAccess

Method Detail

aMapWithSizeback to summary
public static <K, V> Matcher<Map<? extends K, ? extends V>> aMapWithSize(Matcher<? super Integer> sizeMatcher)

Creates a matcher for java.util.Maps that matches when the size() method returns a value that satisfies the specified matcher. For example:

assertThat(myMap, is(aMapWithSize(equalTo(2))))
Parameters
sizeMatcher:Matcher<? super Integer>

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

aMapWithSizeback to summary
public static <K, V> Matcher<Map<? extends K, ? extends V>> aMapWithSize(int size)

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

assertThat(myMap, is(aMapWithSize(2)))
Parameters
size:int

the expected size of an examined java.util.Map

anEmptyMapback to summary
public static <K, V> Matcher<Map<? extends K, ? extends V>> anEmptyMap()

Creates a matcher for java.util.Maps that matches when the size() method returns zero. For example:

assertThat(myMap, is(anEmptyMap()))
featureValueOfback to summary
protected Integer featureValueOf(Map<? extends K, ? extends V> actual)

Implements abstract org.hamcrest.FeatureMatcher.featureValueOf.

Doc from org.hamcrest.FeatureMatcher.featureValueOf.

Implement this to extract the interesting feature.

Parameters
actual:Map<? extends K, ? extends V>

the target object

Returns:Integer

the feature to be matched

Annotations
@Override