View Javadoc
1   package com.puppycrawl.tools.checkstyle.checks.coding.defaultcomeslast;
2   
3   
4   public class InputDefaultComesLast
5   {
6       void method(int i) {
7           // switch with last default
8           switch (i) {
9           case 1: break;
10          case 2: break;
11          default: 
12              // do something :)
13          }
14          
15          // switch w/o default (not a problem)
16          switch (i) {
17          case 1: break;
18          case 2: break;
19          }
20  
21          // VIOLATION!!! default is not the last one.
22          switch (i) {
23          case 1:
24              break;
25          default: /**default is not last*/
26              break;
27          case 2:
28              break;
29          }
30          
31          switch (i) {
32          case 1: break; default: break; case 2: break;  
33          }
34  
35          switch (i) {
36              case 1:
37              default: //violation
38                  break;
39              case 2:
40                  break;
41          }
42  
43          switch (i) {
44              case 1:
45              default: //violation
46              case 2:
47                  break;
48              case 3:
49                  break;
50          }
51  
52          switch (i) {
53              default: //violation
54              case 1:
55                  break;
56              case 2:
57                  break;
58          }
59  
60          switch (i) {
61              case 0: default: case 1: break; case 2: break; //violation
62          }
63  
64          switch (i) {
65              default: case 1: break; case 2: break; //violation
66          }
67  
68          switch (i) {
69              case 1: default: break; case 2: break; //violation
70          }
71  
72          switch (i) {
73              case 1:
74              default: //violation
75                  break;
76              case 2:
77                  break;
78              case 3:
79                  break;
80          }
81  
82          switch (i) {
83              case 1:
84                  break;
85              default: //violation
86              case 2:
87                  break;
88              case 3:
89                  break;
90          }
91  
92          switch (i) {
93              case 1:
94                  break;
95              case 2:
96              default: //violation
97                  break;
98              case 3:
99                  break;
100         }
101 
102         switch (i) {
103             case 1:
104                 break;
105             case 2:
106             default: //violation
107             case 3:
108                 break;
109             case 4:
110                 break;
111         }
112 
113         switch (i) {
114             default: //violation
115                 break;
116             case 1:
117                 break;
118         }
119 
120         switch (i) {
121             case 1:
122                 break;
123             case 2:
124                 break;
125             default: //violation
126             case 5:
127             case 6:
128                 break;
129             case 7:
130                 break;
131         }
132     }
133 }
134 
135 @interface InputDefaultComesLastAnnotation
136 {
137     int blag() default 1;
138 }