18 lines
546 B
Java
18 lines
546 B
Java
// patterns/shapes/FactoryTest.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.
|
|
package patterns.shapes;
|
|
import java.util.stream.*;
|
|
|
|
public class FactoryTest {
|
|
public static void test(FactoryMethod factory) {
|
|
Stream.of("Circle", "Square", "Triangle",
|
|
"Square", "Circle", "Circle", "Triangle")
|
|
.map(factory::create)
|
|
.peek(Shape::draw)
|
|
.peek(Shape::erase)
|
|
.count(); // Terminal operation
|
|
}
|
|
}
|