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

Method test

validating/GuavaPreconditions.java:10–21  ·  view source on GitHub ↗
(Consumer<String> c, String s)

Source from the content-addressed store, hash-verified

8
9public class GuavaPreconditions {
10 static void test(Consumer<String> c, String s) {
11 try {
12 System.out.println(s);
13 c.accept(s);
14 System.out.println("Success");
15 } catch(Exception e) {
16 String type = e.getClass().getSimpleName();
17 String msg = e.getMessage();
18 System.out.println(type +
19 (msg == null ? "" : ": " + msg));
20 }
21 }
22 public static void main(String[] args) {
23 test(s -> s = checkNotNull(s), "X");
24 test(s -> s = checkNotNull(s), null);

Callers 1

mainMethod · 0.95

Calls 2

getMessageMethod · 0.80
acceptMethod · 0.65

Tested by

no test coverage detected