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

Class Matching

streams/Matching.java:13–30  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11 BiPredicate<Stream<Integer>, Predicate<Integer>> {}
12
13public class Matching {
14 static void show(Matcher match, int val) {
15 System.out.println(
16 match.test(
17 IntStream.rangeClosed(1, 9)
18 .boxed()
19 .peek(n -> System.out.format("%d ", n)),
20 n -> n < val));
21 }
22 public static void main(String[] args) {
23 show(Stream::allMatch, 10);
24 show(Stream::allMatch, 4);
25 show(Stream::anyMatch, 2);
26 show(Stream::anyMatch, 0);
27 show(Stream::noneMatch, 5);
28 show(Stream::noneMatch, 0);
29 }
30}
31/* Output:
321 2 3 4 5 6 7 8 9 true
331 2 3 4 false

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected