3434
3535import java .util .Map ;
3636
37- import org .assertj .core .api .AbstractObjectAssert ;
37+ import org .assertj .core .api .AbstractAssert ;
3838import org .assertj .core .api .Condition ;
3939import org .assertj .core .error .GroupTypeDescription ;
4040import org .eclipse .collections .api .RichIterable ;
4848/**
4949 * Base class for all implementations of assertions for {@link Multimap}.
5050 *
51- * @param <SELF> the "self" type of this assertion class.
52- * @param <ACTUAL> the type of the "actual" value.
53- * @param <KEY> the type of keys in the Multimap.
54- * @param <VALUE> the type of values in the Multimap.
51+ * @param <KEY> the type of keys in the Multimap.
52+ * @param <VALUE> the type of values in the Multimap.
5553 */
56- public abstract class AbstractMultimapAssert <SELF extends AbstractMultimapAssert <SELF , ACTUAL , KEY , VALUE >, ACTUAL extends Multimap <KEY , VALUE >, KEY , VALUE >
57- extends AbstractObjectAssert <SELF , ACTUAL > {
54+ public class MultimapAssert <KEY , VALUE > extends AbstractAssert <MultimapAssert <KEY , VALUE >, Multimap <KEY , VALUE >> {
5855
5956 /**
60- * Creates a new {@link AbstractMultimapAssert}.
57+ * Creates a new {@link MultimapAssert}.
58+ *
6159 * @param actual The actual Multimap to assert against
62- * @param selfType The "self" type of child assert class
6360 */
64- protected AbstractMultimapAssert ( ACTUAL actual , Class <?> selfType ) {
65- super (actual , selfType );
61+ public MultimapAssert ( Multimap < KEY , VALUE > actual ) {
62+ super (actual , MultimapAssert . class );
6663 }
6764
6865 /**
@@ -85,7 +82,7 @@ protected AbstractMultimapAssert(ACTUAL actual, Class<?> selfType) {
8582 * @throws AssertionError if the actual {@link Multimap} does not contain the given entries
8683 */
8784 @ SafeVarargs
88- public final SELF contains (Pair <KEY , VALUE >... entries ) {
85+ public final MultimapAssert < KEY , VALUE > contains (Pair <KEY , VALUE >... entries ) {
8986 return this .containsForProxy (Lists .mutable .of (entries ));
9087 }
9188
@@ -98,7 +95,7 @@ public final SELF contains(Pair<KEY, VALUE>... entries) {
9895 * @throws AssertionError if the actual {@code Multimap} does not contain one or more of the specified entries.
9996 */
10097 @ SafeVarargs
101- public final SELF contains (Map .Entry <KEY , VALUE >... entries ) {
98+ public final MultimapAssert < KEY , VALUE > contains (Map .Entry <KEY , VALUE >... entries ) {
10299 MutableList <Pair <KEY , VALUE >> pairs = Lists .mutable .of (entries ).collect (Tuples ::pairFrom );
103100 return this .containsForProxy (pairs );
104101 }
@@ -110,7 +107,7 @@ public final SELF contains(Map.Entry<KEY, VALUE>... entries) {
110107 * @return this assertion object for method chaining.
111108 * @throws AssertionError if the actual {@code Multimap} does not contain one or more of the specified entries.
112109 */
113- protected SELF containsForProxy (MutableList <Pair <KEY , VALUE >> entries ) {
110+ protected MultimapAssert < KEY , VALUE > containsForProxy (MutableList <Pair <KEY , VALUE >> entries ) {
114111 this .isNotNull ();
115112 MutableList <Pair <KEY , VALUE >> entriesNotFound = entries
116113 .reject (entry -> this .actual .containsKeyAndValue (entry .getOne (), entry .getTwo ()));
@@ -130,7 +127,7 @@ protected SELF containsForProxy(MutableList<Pair<KEY, VALUE>> entries) {
130127 * @see #contains(Pair[])
131128 * @see #contains(Map.Entry[])
132129 */
133- public SELF containsEntry (KEY key , VALUE value ) {
130+ public MultimapAssert < KEY , VALUE > containsEntry (KEY key , VALUE value ) {
134131 return this .contains (Tuples .pair (key , value ));
135132 }
136133
@@ -152,7 +149,7 @@ public SELF containsEntry(KEY key, VALUE value) {
152149 * @return this assertion object for method chaining.
153150 * @throws AssertionError if the actual {@link Multimap} does not contain the given keys.
154151 */
155- public SELF containsKeys (KEY ... keys ) {
152+ public MultimapAssert < KEY , VALUE > containsKeys (KEY ... keys ) {
156153 this .isNotNull ();
157154 MutableList <KEY > keysNotFound = Lists .mutable .of (keys ).reject (this .actual ::containsKey );
158155 if (keysNotFound .isEmpty ()) {
@@ -169,7 +166,7 @@ public SELF containsKeys(KEY... keys) {
169166 * @throws AssertionError if the actual {@link Multimap} does not contain only the given entries.
170167 */
171168 @ SafeVarargs
172- public final SELF containsOnly (Map .Entry <? extends KEY , ? extends VALUE >... entries ) {
169+ public final MultimapAssert < KEY , VALUE > containsOnly (Map .Entry <? extends KEY , ? extends VALUE >... entries ) {
173170 MutableList <Pair <? extends KEY , ? extends VALUE >> pairs = Lists .mutable .of (entries ).collect (Tuples ::pairFrom );
174171 return this .containsOnlyForProxy (pairs );
175172 }
@@ -182,7 +179,7 @@ public final SELF containsOnly(Map.Entry<? extends KEY, ? extends VALUE>... entr
182179 * @throws AssertionError if the actual {@link Multimap} does not contain only the given entries.
183180 */
184181 @ SafeVarargs
185- public final SELF containsOnly (Pair <? extends KEY , ? extends VALUE >... entries ) {
182+ public final MultimapAssert < KEY , VALUE > containsOnly (Pair <? extends KEY , ? extends VALUE >... entries ) {
186183 return this .containsOnlyForProxy (Lists .mutable .of (entries ));
187184 }
188185
@@ -193,7 +190,7 @@ public final SELF containsOnly(Pair<? extends KEY, ? extends VALUE>... entries)
193190 * @return this assertion object for method chaining
194191 * @throws AssertionError if the actual {@link Multimap} does not contain only the given entries.
195192 */
196- protected SELF containsOnlyForProxy (MutableList <Pair <? extends KEY , ? extends VALUE >> entries ) {
193+ protected MultimapAssert < KEY , VALUE > containsOnlyForProxy (MutableList <Pair <? extends KEY , ? extends VALUE >> entries ) {
197194 this .isNotNull ();
198195 PartitionMutableList <Pair <? extends KEY , ? extends VALUE >> partition = entries
199196 .partition (entry -> this .actual .containsKeyAndValue (entry .getOne (), entry .getTwo ()));
@@ -217,7 +214,7 @@ protected SELF containsOnlyForProxy(MutableList<Pair<? extends KEY, ? extends VA
217214 * @return the current assertion object for method chaining
218215 * @throws AssertionError if the actual map does not contain the given values
219216 */
220- public SELF containsValues (VALUE ... values ) {
217+ public MultimapAssert < KEY , VALUE > containsValues (VALUE ... values ) {
221218 this .isNotNull ();
222219 MutableList <VALUE > valuesNotFound = Lists .mutable .of (values ).reject (this .actual ::containsValue );
223220 if (valuesNotFound .isEmpty ()) {
@@ -233,7 +230,7 @@ public SELF containsValues(VALUE... values) {
233230 * @return this assertion object for method chaining.
234231 * @throws AssertionError if the actual number of distinct keys in the {@code Multimap} does not match the expected size.
235232 */
236- public SELF hasDistinctSize (int expected ) {
233+ public MultimapAssert < KEY , VALUE > hasDistinctSize (int expected ) {
237234 this .isNotNull ();
238235 int actualSize = this .actual .sizeDistinct ();
239236 if (actualSize == expected ) {
@@ -249,7 +246,7 @@ public SELF hasDistinctSize(int expected) {
249246 * @return this assertion object for method chaining.
250247 * @throws AssertionError if the actual distinct size of the {@link Multimap} is not greater than the specified boundary.
251248 */
252- public SELF hasDistinctSizeGreaterThan (int boundary ) {
249+ public MultimapAssert < KEY , VALUE > hasDistinctSizeGreaterThan (int boundary ) {
253250 this .isNotNull ();
254251 int actualSize = this .actual .sizeDistinct ();
255252 if (actualSize > boundary ) {
@@ -265,7 +262,7 @@ public SELF hasDistinctSizeGreaterThan(int boundary) {
265262 * @return this assertion for method chaining
266263 * @throws AssertionError if the distinct size of the collection is less than the specified boundary
267264 */
268- public SELF hasDistinctSizeGreaterThanOrEqualTo (int boundary ) {
265+ public MultimapAssert < KEY , VALUE > hasDistinctSizeGreaterThanOrEqualTo (int boundary ) {
269266 this .isNotNull ();
270267 int actualSize = this .actual .sizeDistinct ();
271268 if (actualSize >= boundary ) {
@@ -282,7 +279,7 @@ public SELF hasDistinctSizeGreaterThanOrEqualTo(int boundary) {
282279 * @throws NullPointerException if the provided condition is null.
283280 * @throws AssertionError if none of the keys in the {@link Multimap} satisfy the given condition.
284281 */
285- public SELF hasKeySatisfying (Condition <? super KEY > keyCondition ) {
282+ public MultimapAssert < KEY , VALUE > hasKeySatisfying (Condition <? super KEY > keyCondition ) {
286283 this .isNotNull ();
287284 requireNonNull (keyCondition , "The condition to evaluate should not be null" );
288285
@@ -312,7 +309,7 @@ public SELF hasKeySatisfying(Condition<? super KEY> keyCondition) {
312309 * @return {@code this} assertion object.
313310 * @throws AssertionError if the actual size of the {@link Multimap} is not equal to the expected size.
314311 */
315- public SELF hasSize (int expected ) {
312+ public MultimapAssert < KEY , VALUE > hasSize (int expected ) {
316313 this .isNotNull ();
317314 int actualSize = this .actual .size ();
318315 if (actualSize == expected ) {
@@ -342,7 +339,7 @@ public SELF hasSize(int expected) {
342339 * @return {@code this} assertion object.
343340 * @throws AssertionError if the actual size of the {@link Multimap} is not between the given boundaries.
344341 */
345- public SELF hasSizeBetween (int lowerBoundary , int higherBoundary ) {
342+ public MultimapAssert < KEY , VALUE > hasSizeBetween (int lowerBoundary , int higherBoundary ) {
346343 this .isNotNull ();
347344 int actualSize = this .actual .size ();
348345 if (actualSize >= lowerBoundary && actualSize <= higherBoundary ) {
@@ -370,7 +367,7 @@ public SELF hasSizeBetween(int lowerBoundary, int higherBoundary) {
370367 * @return {@code this} assertion object.
371368 * @throws AssertionError if the actual size of the {@link Multimap} is not greater than the specified boundary.
372369 */
373- public SELF hasSizeGreaterThan (int boundary ) {
370+ public MultimapAssert < KEY , VALUE > hasSizeGreaterThan (int boundary ) {
374371 this .isNotNull ();
375372 int actualSize = this .actual .size ();
376373 if (actualSize > boundary ) {
@@ -400,7 +397,7 @@ public SELF hasSizeGreaterThan(int boundary) {
400397 * @return {@code this} assertion object for method chaining.
401398 * @throws AssertionError if the actual size of the {@link Multimap} is less than the expected size.
402399 */
403- public SELF hasSizeGreaterThanOrEqualTo (int boundary ) {
400+ public MultimapAssert < KEY , VALUE > hasSizeGreaterThanOrEqualTo (int boundary ) {
404401 this .isNotNull ();
405402 int actualSize = this .actual .size ();
406403 if (actualSize >= boundary ) {
@@ -428,7 +425,7 @@ public SELF hasSizeGreaterThanOrEqualTo(int boundary) {
428425 * @return {@code this} assertion object.
429426 * @throws AssertionError if the actual size of the {@link Multimap} is not less than the expected size.
430427 */
431- public SELF hasSizeLessThan (int boundary ) {
428+ public MultimapAssert < KEY , VALUE > hasSizeLessThan (int boundary ) {
432429 this .isNotNull ();
433430 int actualSize = this .actual .size ();
434431 if (actualSize < boundary ) {
@@ -457,7 +454,7 @@ public SELF hasSizeLessThan(int boundary) {
457454 * @return {@code this} assertion object for method chaining.
458455 * @throws AssertionError if the actual size of the {@link Multimap} is greater than the expected size.
459456 */
460- public SELF hasSizeLessThanOrEqualTo (int boundary ) {
457+ public MultimapAssert < KEY , VALUE > hasSizeLessThanOrEqualTo (int boundary ) {
461458 this .isNotNull ();
462459 int actualSize = this .actual .size ();
463460 if (actualSize <= boundary ) {
@@ -474,7 +471,7 @@ public SELF hasSizeLessThanOrEqualTo(int boundary) {
474471 * @throws NullPointerException if the provided condition is null.
475472 * @throws AssertionError if none of the values in the {@link Multimap} satisfy the given condition.
476473 */
477- public SELF hasValueSatisfying (Condition <? super VALUE > valueCondition ) {
474+ public MultimapAssert < KEY , VALUE > hasValueSatisfying (Condition <? super VALUE > valueCondition ) {
478475 this .isNotNull ();
479476 requireNonNull (valueCondition , "The condition to evaluate should not be null" );
480477
@@ -522,7 +519,7 @@ public void isEmpty() {
522519 * @return this assertion object for method chaining
523520 * @throws AssertionError if the {@link Multimap} of values is empty.
524521 */
525- public SELF isNotEmpty () {
522+ public MultimapAssert < KEY , VALUE > isNotEmpty () {
526523 this .isNotNull ();
527524 if (!this .actual .isEmpty ()) {
528525 return this .myself ;
0 commit comments