The document describes how to group persons from a yellow pages directory according to the company they work for. It involves creating a Company class with attributes like name, foundation year, persons, and area. A list of Company objects should then be made, with each company containing a list of Person instances. The tasks are to list company names, process a company property as a stream, find the oldest company, count persons using stream operations, concatenate all person names, print persons from each company stream, find unique persons by phone number, implement a custom collector, and compare stream and parallel stream performance on a large dataset.
The document describes how to group persons from a yellow pages directory according to the company they work for. It involves creating a Company class with attributes like name, foundation year, persons, and area. A list of Company objects should then be made, with each company containing a list of Person instances. The tasks are to list company names, process a company property as a stream, find the oldest company, count persons using stream operations, concatenate all person names, print persons from each company stream, find unique persons by phone number, implement a custom collector, and compare stream and parallel stream performance on a large dataset.
The document describes how to group persons from a yellow pages directory according to the company they work for. It involves creating a Company class with attributes like name, foundation year, persons, and area. A list of Company objects should then be made, with each company containing a list of Person instances. The tasks are to list company names, process a company property as a stream, find the oldest company, count persons using stream operations, concatenate all person names, print persons from each company stream, find unique persons by phone number, implement a custom collector, and compare stream and parallel stream performance on a large dataset.
It is desired to group some persons from the yellow pages according to the company
they work for.
Implement the Company class which has a name, the foundation year, a list of persons, an enum specifing the company area(IT, FINANCE..) and other attributes at your liking. Create a list of companies, each containg a list of Person instances.
1. List the names of all companies.
2. Transform one of the object's property into a primitive stream and do some processing on it. 3. Find the oldest company based on the foundation year. 4. Count the persons in the stream using map() and reduce(). 5. Use reduce() to create a Person instance that has the name created as a concatenation of all the other persons' names. 6. Transform a stream of companies in one of persons, in this way printing all the persons that are employed. 7. Display the unique persons using distinct(). Two persons are considered to be identical if they have the same phone number. 8. Implement a custom collector and print the results of applying it on a stream. 9. Create a big stream (at least 1000 elements). Use stream and parallelStream and some processing operations. Measure the results (e.g. "Stream took x seconds / ParallelStream took y seconds").