| 8 | |
| 9 | public class ApplyTest { |
| 10 | public static |
| 11 | void main(String[] args) throws Exception { |
| 12 | List<Shape> shapes = |
| 13 | Suppliers.create(ArrayList::new, Shape::new, 3); |
| 14 | Apply.apply(shapes, |
| 15 | Shape.class.getMethod("rotate")); |
| 16 | Apply.apply(shapes, |
| 17 | Shape.class.getMethod("resize", int.class), 7); |
| 18 | |
| 19 | List<Square> squares = |
| 20 | Suppliers.create(ArrayList::new, Square::new, 3); |
| 21 | Apply.apply(squares, |
| 22 | Shape.class.getMethod("rotate")); |
| 23 | Apply.apply(squares, |
| 24 | Shape.class.getMethod("resize", int.class), 7); |
| 25 | |
| 26 | Apply.apply(new FilledList<>(Shape::new, 3), |
| 27 | Shape.class.getMethod("rotate")); |
| 28 | Apply.apply(new FilledList<>(Square::new, 3), |
| 29 | Shape.class.getMethod("rotate")); |
| 30 | |
| 31 | SimpleQueue<Shape> shapeQ = Suppliers.fill( |
| 32 | new SimpleQueue<>(), SimpleQueue::add, |
| 33 | Shape::new, 3); |
| 34 | Suppliers.fill(shapeQ, SimpleQueue::add, |
| 35 | Square::new, 3); |
| 36 | Apply.apply(shapeQ, |
| 37 | Shape.class.getMethod("rotate")); |
| 38 | } |
| 39 | } |
| 40 | /* Output: |
| 41 | Shape 0 rotate |