View Javadoc
1   /*
2   ParameterNumber
3   max = 2
4   ignoreAnnotatedBy = MyAnno, Session
5   
6   */
7   
8   package com.puppycrawl.tools.checkstyle.checks.sizes.parameternumber;
9   
10  public class InputParameterNumberIgnoreAnnotatedBy {
11      @MyAnno
12      InputParameterNumberIgnoreAnnotatedBy(int a, int b, int c) {}
13  
14      void method1(int a, int b) {}
15  
16      @MyAnno
17      void method2(int a, int b, int c) {}
18  
19      @Session(uid = "Y2K")
20      void method3(int a, int b, int c, int d) {}
21  
22      @Wawa
23      void method5(int a, int b, int c) { // violation, 'More than 2 parameters (found 3).'
24      }
25  
26      @Wawa
27      void method6(int a, int b) {}
28  
29  
30      void method7(int a, int b, int c, int d) { // violation, 'More than 2 parameters (found 4).'
31      }
32  
33      class InnerClass extends InputParameterNumberIgnoreAnnotatedBy {
34          @Override
35          void method2(int a, int b, int c) { // violation, 'More than 2 parameters (found 3).'
36              int d = a + c;
37          }
38  
39          InnerClass(int a, int b) {
40              super(1, 2, 3);
41          }
42  
43          InnerClass(int a, int b, int c, int d) { // violation, 'More than 2 parameters (found 4).'
44              super(1, 2, 3);
45          }
46      }
47  
48      static class Very {
49          static class Deep {
50              static class Rabbit {
51                  enum Colors {
52                      GOLDEN(1, 2, 3) {
53                          void jump(int a, int b) {}
54                          @MyAnno
55                          void roll(int a, int b, int c) {}
56  
57                          // violation below, 'More than 2 parameters (found 3).'
58                          void loaf(int a, int b, int c) {}
59                      };
60  
61                      @Wawa
62                      private Colors(@MyAnno int a, int b, int c) {}
63                      // violation above, 'More than 2 parameters (found 3).'
64  
65                      @Session(uid = ":D")
66                      private Colors(@Wawa int a, @Wawa int b, @Wawa int c, @Wawa int d) {}
67  
68                      private Colors(int a) {}
69                  }
70                  static class Hole {
71                      static {
72                          new Object() {
73                              @MyAnno @Session(uid = "G0F")
74                              void method1(int a, int b, int c) {}
75  
76                              // violation below, 'More than 2 parameters (found 4).'
77                              void method3(@MyAnno int a, @MyAnno int b, @MyAnno int c, int d) {}
78                          };
79                      }
80                  }
81              }
82          }
83      }
84  
85      @Wawa
86      @MyAnno
87      void method8(int a, int b, int c) {
88      }
89  
90      @Session(uid = "H1") @Bit
91      @Wawa
92      void method9(int a, int b, int c) {
93      }
94  
95      @Bit
96      @Wawa
97      void method10(int a, int b, int c) { // violation, 'More than 2 parameters (found 3).'
98      }
99  
100     interface Reader {
101         void method1 (int a, int b);
102 
103         @MyAnno
104         void method2 (int a, int b, int c);
105 
106         void method3 (int a, int b, int c); // violation, 'More than 2 parameters (found 3).'
107     }
108 
109     @interface Wawa {}
110     @interface Bit {}
111     @interface MyAnno {}
112     @interface Session {
113         String uid();
114     }
115 }