View Javadoc
1   /*
2   VisibilityModifier
3   packageAllowed = (default)false
4   protectedAllowed = (default)false
5   publicMemberPattern = ^f[A-Z][a-zA-Z0-9]*$
6   allowPublicFinalFields = (default)false
7   allowPublicImmutableFields = (default)false
8   immutableClassCanonicalNames = (default)java.io.File, java.lang.Boolean, java.lang.Byte, \
9                                  java.lang.Character, java.lang.Double, java.lang.Float, \
10                                 java.lang.Integer, java.lang.Long, java.lang.Short, \
11                                 java.lang.StackTraceElement, java.lang.String, \
12                                 java.math.BigDecimal, java.math.BigInteger, \
13                                 java.net.Inet4Address, java.net.Inet6Address, \
14                                 java.net.InetSocketAddress, java.net.URI, java.net.URL, \
15                                 java.util.Locale, java.util.UUID
16  ignoreAnnotationCanonicalNames = (default)com.google.common.annotations.VisibleForTesting, \
17                                   org.junit.ClassRule, org.junit.Rule
18  
19  
20  */
21  
22  package com.puppycrawl.tools.checkstyle.checks.design.visibilitymodifier;
23  
24  /**
25   * Tests having inner types
26   * @author Oliver Burn
27   **/
28  class InputVisibilityModifierInner
29  {
30      // Ignore - two violations
31      class InnerInner2
32      {
33          // Ignore
34          public int fData;
35      }
36  
37      // Ignore - 2 violations
38      interface InnerInterface2
39      {
40          // Ignore - should be all upper case
41          String data = "zxzc";
42  
43          // Ignore
44          class InnerInterfaceInnerClass
45          {
46              // Ignore - need Javadoc and made private
47              public int rData; // violation
48  
49              /** needs to be made private unless allowProtected. */
50              protected int protectedVariable; // violation
51  
52              /** needs to be made private unless allowPackage. */
53              int packageVariable; // violation
54          }
55      }
56  
57      /** demonstrate bug in handling static final **/
58      protected static Object sWeird = new Object(); // violation
59      /** demonstrate bug in handling static final **/
60      static Object sWeird2 = new Object(); // violation
61  
62      /** demonstrate bug in local final variable */
63      public interface Inter
64      {
65      }
66  
67       public static void main()
68       {
69          Inter m = new Inter()
70          {
71              private static final int CDS = 1;
72  
73              private int ABC;
74          };
75       }
76  
77      /** annotation field incorrectly named. */
78      @interface InnerAnnotation
79      {
80          /** Ignore - should be all upper case. */
81          String data = "zxzc";
82      }
83  
84      /** enum with public member variable */
85      enum InnerEnum
86      {
87          /** First constant */
88          A,
89  
90          /** Second constant */
91          B;
92  
93          /** Should be private */
94          public int someValue; // violation
95      }
96  
97      float fSerialVersionUID = 0x1234567F; // violation
98  }