The previous recipe provided with the process for how to generate the Stream objects from a source data structure. It is time to scrutinize and study the operations involved in stream objects:
- Open again the class EmployeeStreamService in the package org.packt.functional.codes.service.impl and add this set of methods that initializes Employee, arrays and converts List<Employee> to Employee[] using some Stream methods:
public Stream<Employee> createEmptyArrayStream(){ Stream<Employee> stream = Stream.empty(); return stream; } public Stream<Employee> createUnlimitedStream(){ Stream<Employee> stream = Stream.generate(() -> {return new Employee();}) .limit(10); return stream; } public Stream<Employee> createArrayFromOf(Employee[] ...