MCPcopy Index your code
hub / github.com/BruceEckel/OnJava8-Examples / main

Method main

generics/ApplyTest.java:10–38  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

8
9public 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:
41Shape 0 rotate

Callers

nothing calls this directly

Calls 3

createMethod · 0.95
applyMethod · 0.95
fillMethod · 0.95

Tested by

no test coverage detected