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