View Javadoc
1   /*xml
2   <module name="Checker">
3     <module name="TreeWalker">
4       <module name="VisibilityModifier">
5         <property name="ignoreAnnotationCanonicalNames"
6                   value="java.lang.Deprecated"/>
7       </module>
8     </module>
9   </module>
10  
11  
12  */
13  
14  package com.puppycrawl.tools.checkstyle.checks.design.visibilitymodifier;
15  
16  import com.google.common.collect.ImmutableMap;
17  import com.google.common.collect.ImmutableSet;
18  
19  import java.util.HashSet;
20  import java.util.Set;
21  
22  // xdoc section -- start
23  class Example8 {
24    private int myPrivateField1;
25  
26    int field1; // violation, must have visibility modifier 'must be private'
27  
28    protected String field2; // violation, protected not allowed 'must be private'
29  
30    // violation below, not final nor matching pattern 'must be private'
31    public int field3 = 42;
32  
33    public long serialVersionUID = 1L;
34  
35    public static final int field4 = 42;
36  
37    public final int field5 = 42; // violation 'must be private'
38  
39    public final java.lang.String notes = null; // violation 'must be private'
40  
41    // violation below, HashSet is mutable 'must be private'
42    public final Set<String> mySet1 = new HashSet<>();
43  
44    // violation below, immutable type not in config 'must be private'
45    public final ImmutableSet<String> mySet2 = null;
46  
47    // violation below, immutable type not in config 'must be private'
48    public final ImmutableMap<String, Object> objects1 = null;
49  
50    @java.lang.Deprecated
51    String annotatedString;
52  
53    @Deprecated
54    String shortCustomAnnotated;
55  
56    @com.google.common.annotations.VisibleForTesting
57    // violation below, annotation not configured 'must be private'
58    public String testString = "";
59  }
60  // xdoc section -- end