How to do it...

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:

  1. 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[] ...

Get Spring 5.0 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.