View Javadoc
1   /*
2   RightCurly
3   option = ALONE_OR_SINGLELINE
4   tokens = LITERAL_SWITCH, LITERAL_IF, LITERAL_TRY, LITERAL_CATCH
5   
6   
7   */
8   
9   package com.puppycrawl.tools.checkstyle.checks.blocks.rightcurly;
10  
11  public class InputRightCurlyTestSwitchCase2 {
12  
13      public static void method0() {
14          int mode = 0;
15          switch (mode) {
16              case 1:
17                  int x = 1;
18                  break;
19              default :
20                  x = 0; } // violation '}' at column 24 should be alone on a line'
21      }
22  
23      public static void method1() {
24          int mode = 0;
25          switch (mode) {
26          default :
27                 int x = 0; } // violation '}' at column 27 should be alone on a line'
28      }
29  
30      public static void method2() {
31          int mode = 0;
32          switch (mode) {
33              case 1:
34                  int x = 1;
35                  break;
36              default:
37                  x = 0;
38          }
39      }
40  
41      public static void method3() {
42          int mode = 0;
43          switch (mode) {
44          default :
45                 int x = 0;
46          }
47      }
48  
49      public static void method4() {
50          int mode = 0;
51          switch (mode) { default : int x = 0; }
52      }
53  
54      public static void method5() {
55          int mode = 0;
56          switch (mode) { default : int x = 0;
57          }
58      }
59  
60      public static void method6() {
61          int mode = 0;
62          switch (mode) { case 0: int x = 1; break; default : x = 5;
63          }
64      }
65  
66      public static void method7() {
67          int mode = 0;
68          switch (mode) { case 0: int x = 1; break; default : x = 5; }
69      }
70  
71      public static void method8() {
72          int mode = 0;
73          switch (mode) { case 0: int x = 1; break; case 80: x = 1; break; }
74      }
75  
76      public static void method9() {
77          int mode = 0;
78          switch (mode) { case 0: int x = 1; break; default : x = 5;
79          }
80      }
81  
82      public static void method10() {
83          int mode = 0;
84          switch (mode) { case 0: int x = 1; break; case 80: x = 1; break;
85          }
86      }
87  
88      public static void method11() {
89          int mode = 0;
90          int x = 0;
91          switch (mode) {
92              case 0:
93                  if(0>9) {
94                      x = 9;
95                  }
96                  break;
97              case 80:
98                  x = 1;
99                  break;
100         }
101     }
102 
103     public static void method12() {
104         int num = 5;
105         try {
106             switch (num) {
107                 case 1:
108                 try {
109                         System.out.println("Number is 1");
110                         break;
111                 }
112                 catch (Exception ignored) {}
113             }
114         } catch (IllegalArgumentException e) { // violation 'at column 9 should be alone on a line'
115             System.err.println(e.getMessage());
116         }
117     }
118 }