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