View Javadoc
1   /*xml
2   <module name="Checker">
3     <module name="TreeWalker">
4       <module name="HiddenField">
5         <property name="ignoreSetter" value="true"/>
6         <property name="setterCanReturnItsClass" value="true"/>
7       </module>
8     </module>
9   </module>
10  */
11  package com.puppycrawl.tools.checkstyle.checks.coding.hiddenfield;
12  
13  // xdoc section -- start
14  class Example6 {
15  
16    private String field;
17    private String testField;
18  
19    Example6(String testField) { // violation, ''testField' hides a field'
20    }
21    void method(String param) {
22      String field = param; // violation, ''field' hides a field'
23    }
24    void setTestField(String testField) { // OK, because ignoreSetter is true
25      this.field = field;
26    }
27    Example6 setField(String field) { // OK, because setterCanReturnItsClass is true
28      this.field = field;
29      return null;
30    }
31    abstract class Inner {
32      abstract int method(String field); // violation, ''field' hides a field'
33    }
34  }
35  // xdoc section -- end