// generics/ApplyFunctional.java
// (c)2021 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://OnJava8.com for more book information.
import java.util.*;
import java.util.stream.*;
import java.util.function.*;
import onjava.*;
public class ApplyFunctional {
public static void main(String[] args) {
Stream.of(
Stream.generate(Shape::new).limit(2),
Stream.generate(Square::new).limit(2))
.flatMap(c -> c) // flatten into one stream
.peek(Shape::rotate)
.forEach(s -> s.resize(7));
new FilledList<>(Shape::new, 2)
.forEach(Shape::rotate);
new FilledList<>(Square::new, 2)
.forEach(Shape::rotate);
SimpleQueue