Testing time

MelonCollector can be used via the new keyword, as follows:

Map<Boolean, List<Melon>> melons2000 = melons.stream()
.collect(new MelonCollector());

We will receive the following output:

{
false = [Crenshaw(1200 g),Hemi(1600 g),Gac(1200 g),Horned(1700 g)],
true = [Gac(3000 g),Hemi(2600 g),Apollo(2600 g),
Gac(3000 g),Hemi(2600 g)]
}

We can also use it via parallelStream():

Map<Boolean, List<Melon>> melons2000 = melons.parallelStream()
.collect(new MelonCollector());

If we use the combiner() method, then the output may look as follows:

{false = [], true = [Hemi(2600g)]} 
ForkJoinPool.commonPool - worker - 7
...
{false = [Horned(1700g)], true = []}
ForkJoinPool.commonPool - worker - 15
{false = [Crenshaw(1200g)], true = [Gac(3000g)]}
ForkJoinPool.commonPool - worker - 9
...
{false = [Crenshaw(1200g), Hemi(1600g), Gac(1200g), Horned(1700g)],
true = [Gac(3000g), Hemi(2600g), Apollo(2600g),
Gac(3000g), Hemi(2600g)]}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.31.163