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

Method apply

generics/Apply.java:9–20  ·  view source on GitHub ↗
(S seq, Method f, Object... args)

Source from the content-addressed store, hash-verified

7
8public class Apply {
9 public static <T, S extends Iterable<T>>
10 void apply(S seq, Method f, Object... args) {
11 try {
12 for(T t: seq)
13 f.invoke(t, args);
14 } catch(IllegalAccessException |
15 IllegalArgumentException |
16 InvocationTargetException e) {
17 // Failures are programmer errors
18 throw new RuntimeException(e);
19 }
20 }
21}

Callers 1

mainMethod · 0.95

Calls 1

invokeMethod · 0.45

Tested by 1

mainMethod · 0.76