1   package com.puppycrawl.tools.checkstyle.checks.blocks.rightcurly;
2   
3   import java.util.stream.Collectors;
4   import java.util.stream.Stream;
5   
6   public class InputRightCurlySameLambda {
7   
8       static Runnable r1 = () -> {
9           String.valueOf("Test rightCurly one!");
10      };
11  
12      static Runnable r2 = () -> String.valueOf("Test rightCurly two!");
13  
14      static Runnable r3 = () -> {String.valueOf("Test rightCurly three!");};
15  
16      static Runnable r4 = () -> {
17          String.valueOf("Test rightCurly four!");};    //violation
18  
19      static Runnable r5 = () ->
20      {
21          String.valueOf("Test rightCurly five!");
22      };
23  
24      static Runnable r6 = () -> {};
25  
26      static Runnable r7 = () -> {
27      };
28  
29      static Runnable r8 = () ->
30      {
31      };
32  
33      static Runnable r9 = () -> {
34          String.valueOf("Test rightCurly nine!");
35      }; int i;       // violation
36  
37      void foo1() {
38          Stream.of("Hello").filter(s -> {
39                  return s != null;
40              }       // violation
41          ).collect(Collectors.toList());
42  
43          Stream.of("Hello").filter(s -> {
44                  return s != null;
45          }).collect(Collectors.toList());
46  
47          Stream.of("Hello").filter(s -> {return s != null;})
48                  .collect(Collectors.toList());
49  
50          Stream.of("Hello").filter(s -> {return s != null;}).collect(Collectors.toList());
51  
52          Stream.of("Hello").filter(s -> {
53              return s != null;}).collect(Collectors.toList()); // violation
54  
55          bar(() -> {return;}, () -> {return;});
56  
57          bar(() -> {
58              return;
59          }, () -> {return;});
60  
61          bar(() -> {
62              return;
63          }, () -> {
64              return;
65          });
66  
67          bar(() -> {
68              return;}, () -> {return;}); // violation
69  
70          bar(() -> {
71              return;
72          }, () -> {
73              return;}); // violation
74  
75      }
76  
77      void bar(Runnable r1, Runnable r2) { }
78  }