View Javadoc
1   package com.puppycrawl.tools.checkstyle.checks.design.designforextension;
2   
3   public class InputDesignForExtensionOverridableMethods {
4   
5       public class A {
6           public int foo1(int a, int b) {return a + b;} // violation
7   
8           public void foo2() { }
9   
10          public void foo3(int a, int b) { }
11  
12          private int foo4(int a, int b) {return a + b;}
13  
14          public void foo5() {
15              // single line comment is not counted as a content
16          }
17  
18          public void foo6() {
19              /**
20               * javadoc block comment is not counted as a content
21               */
22          }
23  
24          public void foo7() {
25              /*
26               * block comment is not counted as a content
27               */
28          }
29  
30          public int foo8(int a, int b) { // violation
31              // single line comment before content
32              return a + b;
33          }
34  
35          public int foo9(int a, int b) { // violation
36              /*
37               * block comment before content
38               */
39              return a + b;
40          }
41  
42          public int foo10(int a, int b) { // violation
43              /**
44               * javadoc block comment before content
45               */
46              return a + b;
47          }
48  
49          public int foo11(int a, int b) { // violation
50              return a + b;
51              // single line comment after content
52          }
53  
54          public int foo12(int a, int b) { // violation
55              return a + b;
56              /*
57               * block comment after content
58               */
59          }
60  
61          public int foo13(int a, int b) { // violation
62              return a + b;
63              /**
64               * javadoc block comment after content
65               */
66          }
67  
68          protected int foo14(int a) {return a -1;} // violation
69  
70          public final int foo15(int a) {return a - 2;}
71  
72          protected final int foo16(int a) {return a - 2;}
73  
74          /** Javadoc comment */
75          protected int foo17(int a) {return a -1;}
76  
77          /** Method javadoc */
78          public void foo18() { }
79  
80          /** Method javadoc */
81          public int foo19() {return 1;}
82  
83          /** */
84          public final int foo20(int a) {return a - 2;}
85  
86          /** */
87          protected final int foo21(int a) {return a - 2;}
88  
89          // Single line comment
90          public void foo22() { // violation
91              return;
92          }
93  
94          // Single line comments
95          // organized in a block
96          public void foo23() { // violation
97              return;
98          }
99  
100         // Single line comments
101         // organized in a block
102         public void foo24() {}
103 
104         /* Block comment */
105         public void foo25() {
106             return;
107         }
108 
109         // Single line comment
110         @Deprecated // violation
111         public void foo26() {
112             return;
113         }
114 
115         // Single line comments
116         // organized in a block
117         @Deprecated // violation
118         public void foo27() {
119             return;
120         }
121 
122         /** Javadoc comment */
123         @Deprecated
124         public void foo28() {
125             return;
126         }
127 
128         /* Block comment */
129         @Deprecated
130         public void foo29() {
131             return;
132         }
133 
134         /**
135          * Returns maximum of a and b.
136          * @param a a.
137          * @param b b.
138          * @return maximum of a and b.
139          */
140         public int max(int a, int b) {
141             return Math.max(a, b);
142         }
143 
144         /** */
145         public int foo30() {
146             /** */
147             return 1;
148         }
149 
150         /* */
151         public int foo31() {
152             /** */
153             return 1;
154         }
155 
156         /** */
157         public int foo32() {
158             /* */
159             return 1;
160         }
161 
162         @Deprecated
163         /** */
164         public int foo33() {
165             return 1;
166         }
167 
168         @Deprecated
169         /* */
170         public int foo34() {
171             return 1;
172         }
173 
174         @Deprecated
175         /* */
176         public void foo35() { }
177 
178         @Deprecated
179         /** */
180         public void foo36() { }
181 
182         @Deprecated
183         /** */
184         public void foo37() { /** */ }
185 
186         @Deprecated
187         // comment
188         public void foo38() { }
189 
190         @Deprecated /** */
191         public void foo39() {return; }
192 
193         /**
194          * @param indent indentation to check.
195          * @return true if {@code indent} less then minimal of
196          *         acceptable indentation levels, false otherwise.
197          */
198         public boolean isGreaterThan(int indent) {
199             return indent == 2;
200         }
201 
202         /**
203          * Sets whether to process JavaDoc or not.
204          *
205          * @param value Flag for processing JavaDoc.
206          */
207         public void setProcessJavadoc(boolean value) {
208             value = true;
209         }
210     }
211 
212     public final class B {
213         public int foo1(int a, int b) {return a + b;}
214 
215         protected int foo2(int a, int b) {return a + b;}
216 
217         public final int foo3(int a, int b) {return a + b;}
218 
219         protected final int foo4(int a, int b) {return a + b;}
220     }
221 
222     public abstract class C {
223         public abstract void foo1(int a);
224     }
225 }