/** * @since 10.0.0 */ @Override default <V1> ImmutableBag<V1> countByEach(Function<? super V, ? extends Iterable<V1>> function) { return this.asLazy().flatCollect(function).toBag().toImmutable(); }
/** * Assert that the given {@link ImmutableMapIterable} contains an entry with the given key. */ public static void assertContainsKey( String immutableMapIterableName, Object expectedKey, ImmutableMapIterable<?, ?> immutableMapIterable) { try { Assert.assertNotNull(immutableMapIterableName, immutableMapIterable); if (!immutableMapIterable.containsKey(expectedKey)) { Assert.fail(immutableMapIterableName + " did not contain expectedKey:<" + expectedKey + '>'); } } catch (AssertionError e) { Verify.throwMangledException(e); } }
private static void assertMapContainsKeys( String immutableMapIterableName, ImmutableMapIterable<?, ?> immutableMapIterable, Object... expectedKeyValues) { try { Verify.assertNotEmpty("Expected keys/values in assertion", expectedKeyValues); MutableList<Object> expectedKeys = Lists.mutable.of(); for (int i = 0; i < expectedKeyValues.length; i += 2) { expectedKeys.add(expectedKeyValues[i]); } Verify.assertContainsAll(immutableMapIterableName + ".keysView()", immutableMapIterable.keysView(), expectedKeys.toArray()); } catch (AssertionError e) { Verify.throwMangledException(e); } }
private static void assertMapContainsValues( String immutableMapIterableName, ImmutableMapIterable<?, ?> immutableMapIterable, Object... expectedKeyValues) { try { Verify.assertNotEmpty("Expected keys/values in assertion", expectedKeyValues); MutableList<Object> expectedValues = Lists.mutable.of(); for (int i = 1; i < expectedKeyValues.length; i += 2) { expectedValues.add(expectedKeyValues[i]); } Verify.assertContainsAll(immutableMapIterableName + ".valuesView()", immutableMapIterable.valuesView(), expectedValues.toArray()); } catch (AssertionError e) { Verify.throwMangledException(e); } }
Object actualValue = immutableMapIterable.get(expectedKey); if (!Comparators.nullSafeEquals(actualValue, expectedValue))
private static void assertMapContainsKeys( String immutableMapIterableName, ImmutableMapIterable<?, ?> immutableMapIterable, Object... expectedKeyValues) { try { Verify.assertNotEmpty("Expected keys/values in assertion", expectedKeyValues); MutableList<Object> expectedKeys = Lists.mutable.of(); for (int i = 0; i < expectedKeyValues.length; i += 2) { expectedKeys.add(expectedKeyValues[i]); } Verify.assertContainsAll(immutableMapIterableName + ".keysView()", immutableMapIterable.keysView(), expectedKeys.toArray()); } catch (AssertionError e) { Verify.throwMangledException(e); } }
private static void assertMapContainsValues( String immutableMapIterableName, ImmutableMapIterable<?, ?> immutableMapIterable, Object... expectedKeyValues) { try { Verify.assertNotEmpty("Expected keys/values in assertion", expectedKeyValues); MutableList<Object> expectedValues = Lists.mutable.of(); for (int i = 1; i < expectedKeyValues.length; i += 2) { expectedValues.add(expectedKeyValues[i]); } Verify.assertContainsAll(immutableMapIterableName + ".valuesView()", immutableMapIterable.valuesView(), expectedValues.toArray()); } catch (AssertionError e) { Verify.throwMangledException(e); } }
Object actualValue = immutableMapIterable.get(expectedKey); if (!Comparators.nullSafeEquals(actualValue, expectedValue))
/** * @since 10.0.0 */ @Override default <V1> ImmutableBag<V1> countByEach(Function<? super V, ? extends Iterable<V1>> function) { return this.asLazy().flatCollect(function).toBag().toImmutable(); }
/** * Assert that the given {@link ImmutableMapIterable} contains an entry with the given key. */ public static void assertContainsKey( String immutableMapIterableName, Object expectedKey, ImmutableMapIterable<?, ?> immutableMapIterable) { try { Assert.assertNotNull(immutableMapIterableName, immutableMapIterable); if (!immutableMapIterable.containsKey(expectedKey)) { Assert.fail(immutableMapIterableName + " did not contain expectedKey:<" + expectedKey + '>'); } } catch (AssertionError e) { Verify.throwMangledException(e); } }
/** * @since 9.0 */ @Override default <V1> ImmutableBag<V1> countBy(Function<? super V, ? extends V1> function) { return this.asLazy().<V1>collect(function).toBag().toImmutable(); }
/** * @since 9.0 */ @Override default <V1, P> ImmutableBag<V1> countByWith(Function2<? super V, ? super P, ? extends V1> function, P parameter) { return this.asLazy().<P, V1>collectWith(function, parameter).toBag().toImmutable(); }
/** * @since 9.0 */ @Override default <V1> ImmutableBag<V1> countBy(Function<? super V, ? extends V1> function) { return this.asLazy().<V1>collect(function).toBag().toImmutable(); }
/** * @since 9.0 */ @Override default <V1, P> ImmutableBag<V1> countByWith(Function2<? super V, ? super P, ? extends V1> function, P parameter) { return this.asLazy().<P, V1>collectWith(function, parameter).toBag().toImmutable(); }