@Test public void collectBoolean() { ImmutableCollection<Integer> integers = this.classUnderTest(); ImmutableBooleanCollection immutableCollection = integers.collectBoolean(PrimitiveFunctions.integerIsPositive()); Verify.assertSize(1, immutableCollection); }
@Test public void collectShort() { ImmutableCollection<Integer> integers = this.classUnderTest(); ImmutableShortCollection immutableCollection = integers.collectShort(PrimitiveFunctions.unboxIntegerToShort()); Verify.assertSize(integers.size(), immutableCollection); Assert.assertEquals(integers, immutableCollection.collect(Integer::valueOf)); }
@Override @Test public void collectShort() { MutableBag<Integer> integers = UnmodifiableBag.of(HashBag.newBagWith(1, 2, 2, 3, 3, 3)); Assert.assertEquals( ShortHashBag.newBagWith((short) 1, (short) 2, (short) 2, (short) 3, (short) 3, (short) 3), integers.collectShort(PrimitiveFunctions.unboxIntegerToShort())); }
@Override @Test public void collectLong() { MutableBag<Integer> integers = UnmodifiableBag.of(HashBag.newBagWith(1, 2, 2, 3, 3, 3)); Assert.assertEquals( LongHashBag.newBagWith(1L, 2L, 2L, 3L, 3L, 3L), integers.collectLong(PrimitiveFunctions.unboxIntegerToLong())); }
@Override @Test public void collectFloat() { MutableBag<Integer> integers = UnmodifiableBag.of(HashBag.newBagWith(1, 2, 2, 3, 3, 3)); Assert.assertEquals( FloatHashBag.newBagWith(1.0f, 2.0f, 2.0f, 3.0f, 3.0f, 3.0f), integers.collectFloat(PrimitiveFunctions.unboxIntegerToFloat())); }
@Override @Test public void collectDouble() { MutableBag<Integer> integers = UnmodifiableBag.of(HashBag.newBagWith(1, 2, 2, 3, 3, 3)); Assert.assertEquals( DoubleHashBag.newBagWith(1.0d, 2.0d, 2.0d, 3.0d, 3.0d, 3.0d), integers.collectDouble(PrimitiveFunctions.unboxIntegerToDouble())); }
@Override @Test public void collectByte() { MutableBag<Integer> integers = UnmodifiableBag.of(HashBag.newBagWith(1, 2, 2, 3, 3, 3)); Assert.assertEquals( ByteHashBag.newBagWith((byte) 1, (byte) 2, (byte) 2, (byte) 3, (byte) 3, (byte) 3), integers.collectByte(PrimitiveFunctions.unboxIntegerToByte())); }
@Override @Test public void collectBoolean() { MutableBag<Integer> integers = UnmodifiableBag.of(HashBag.newBagWith(0, 1, 2, 2)); Assert.assertEquals( BooleanHashBag.newBagWith(false, true, true, true), integers.collectBoolean(PrimitiveFunctions.integerIsPositive())); }
@Test public void collectLong() { ImmutableCollection<Integer> integers = this.classUnderTest(); ImmutableLongCollection immutableCollection = integers.collectLong(PrimitiveFunctions.unboxIntegerToLong()); Verify.assertSize(integers.size(), immutableCollection); Assert.assertEquals( integers, immutableCollection.collect(longParameter -> Integer.valueOf((int) longParameter))); }
public <V1> ObjectDoubleMap<V1> sumByDouble( Function<V, V1> groupBy, DoubleFunction<? super V> function) { ObjectDoubleHashMap<V1> result = ObjectDoubleHashMap.newMap(); return this.injectInto(result, PrimitiveFunctions.sumByDoubleFunction(groupBy, function)); }
public <V1> ObjectLongMap<V1> sumByLong( Function<V, V1> groupBy, LongFunction<? super V> function) { ObjectLongHashMap<V1> result = ObjectLongHashMap.newMap(); return this.injectInto(result, PrimitiveFunctions.sumByLongFunction(groupBy, function)); }