Package org.hamcrest.collection
Class IsMapWithSize<K,V>
- java.lang.Object
-
- org.hamcrest.BaseMatcher<T>
-
- org.hamcrest.TypeSafeDiagnosingMatcher<T>
-
- org.hamcrest.FeatureMatcher<java.util.Map<? extends K,? extends V>,java.lang.Integer>
-
- org.hamcrest.collection.IsMapWithSize<K,V>
-
- All Implemented Interfaces:
Matcher<java.util.Map<? extends K,? extends V>>
,SelfDescribing
public final class IsMapWithSize<K,V> extends FeatureMatcher<java.util.Map<? extends K,? extends V>,java.lang.Integer>
Matches if map size satisfies a nested matcher.
-
-
Constructor Summary
Constructors Constructor Description IsMapWithSize(Matcher<? super java.lang.Integer> sizeMatcher)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <K,V>
Matcher<java.util.Map<? extends K,? extends V>>aMapWithSize(int size)
Creates a matcher forMap
s that matches when thesize()
method returns a value equal to the specifiedsize
.static <K,V>
Matcher<java.util.Map<? extends K,? extends V>>aMapWithSize(Matcher<? super java.lang.Integer> sizeMatcher)
Creates a matcher forMap
s that matches when thesize()
method returns a value that satisfies the specified matcher.static <K,V>
Matcher<java.util.Map<? extends K,? extends V>>anEmptyMap()
Creates a matcher forMap
s that matches when thesize()
method returns zero.protected java.lang.Integer
featureValueOf(java.util.Map<? extends K,? extends V> actual)
Implement this to extract the interesting feature.-
Methods inherited from class org.hamcrest.FeatureMatcher
describeTo, matchesSafely
-
Methods inherited from class org.hamcrest.TypeSafeDiagnosingMatcher
describeMismatch, matches
-
Methods inherited from class org.hamcrest.BaseMatcher
_dont_implement_Matcher___instead_extend_BaseMatcher_, isNotNull, toString
-
-
-
-
Constructor Detail
-
IsMapWithSize
public IsMapWithSize(Matcher<? super java.lang.Integer> sizeMatcher)
-
-
Method Detail
-
featureValueOf
protected java.lang.Integer featureValueOf(java.util.Map<? extends K,? extends V> actual)
Description copied from class:FeatureMatcher
Implement this to extract the interesting feature.- Specified by:
featureValueOf
in classFeatureMatcher<java.util.Map<? extends K,? extends V>,java.lang.Integer>
- Parameters:
actual
- the target object- Returns:
- the feature to be matched
-
aMapWithSize
public static <K,V> Matcher<java.util.Map<? extends K,? extends V>> aMapWithSize(Matcher<? super java.lang.Integer> sizeMatcher)
Creates a matcher forMap
s that matches when thesize()
method returns a value that satisfies the specified matcher. For example:assertThat(myMap, is(aMapWithSize(equalTo(2))))
- Parameters:
sizeMatcher
- a matcher for the size of an examinedMap
-
aMapWithSize
public static <K,V> Matcher<java.util.Map<? extends K,? extends V>> aMapWithSize(int size)
Creates a matcher forMap
s that matches when thesize()
method returns a value equal to the specifiedsize
. For example:assertThat(myMap, is(aMapWithSize(2)))
- Parameters:
size
- the expected size of an examinedMap
-
anEmptyMap
public static <K,V> Matcher<java.util.Map<? extends K,? extends V>> anEmptyMap()
Creates a matcher forMap
s that matches when thesize()
method returns zero. For example:assertThat(myMap, is(anEmptyMap()))
-
-