View Javadoc
1   /*
2   EmptyLineSeparator
3   allowNoEmptyLineBetweenFields = true
4   allowMultipleEmptyLines = (default)true
5   allowMultipleEmptyLinesInsideClassMembers = (default)true
6   tokens = (default)PACKAGE_DEF, IMPORT, STATIC_IMPORT, CLASS_DEF, INTERFACE_DEF, ENUM_DEF, \
7            STATIC_INIT, INSTANCE_INIT, METHOD_DEF, CTOR_DEF, VARIABLE_DEF, RECORD_DEF, \
8            COMPACT_CTOR_DEF
9   
10  
11  */
12  
13  package com.puppycrawl.tools.checkstyle.checks.whitespace.emptylineseparator; //ok: trailing comment
14  import java.io.Serializable; // violation ''import' should be separated from previous line.'
15  import java.util.ArrayList; /*ok: trailing comment*/
16  import java.util.HashMap;
17  import java.util.List;
18  import java.util.Map;
19  import java.util.concurrent.Callable;
20  import java.util.Collections;
21  /* ok: block comment after token*/
22  
23  import java.io.PrintWriter;
24  //ok: single-line comment after token
25  
26  import javax.swing.AbstractAction; /* ok: no trailing comment
27  */
28  
29  import org.apache.commons.beanutils.locale.converters.ByteLocaleConverter;
30  import org.apache.commons.beanutils.BasicDynaBean;
31  class InputEmptyLineSeparator2 // violation ''CLASS_DEF' should be separated from previous line.'
32  {
33      public static final double FOO_PI = 3.1415;
34      private boolean flag = true;
35      static { // violation ''STATIC_INIT' should be separated from previous line.'
36          //empty static initializer
37      }
38      // no blank line - fail
39      {
40          //empty // violation above ''INSTANCE_INIT'.*separated.*from.*previous.*line.'
41      }
42  
43      // one blank line - ok
44      {
45          //empty instance initializer
46      }
47      // no blank line - fail
48      /**
49       *
50       *
51       *
52       */
53      private InputEmptyLineSeparator2() // violation ''CTOR_DEF'.*separated.*from.*previous.*line.'
54      {
55          //empty
56      }
57      //separator blank line
58      public int // violation ''METHOD_DEF'.*separated.*from.*previous.*line.'
59      compareTo(Object aObject) {
60          int number = 0;
61          return 0;
62      }
63  
64      public int compareTo2(Object aObject) // empty line - ok
65      {
66          int number = 0;
67          return 0;
68      }
69      /**
70       * No blank line between methods - fail
71       * @param task
72       * @param result
73       * @return
74       */
75      public static <T> Callable<T> // violation ''METHOD_DEF'.*separated.*from.*previous.*line.'
76      callable(Runnable task, T result) {
77          return null;
78      }
79  
80      /**
81       * Blank line before Javadoc - ok
82       * @param task
83       * @param result
84       * @return
85       */
86      public static <T> Callable<T> callable2(Runnable task, T result)
87      {
88          return null;
89      }
90      /**
91       * Blank line after Javadoc - ok
92       * @param task
93       * @param result
94       * @return
95       */
96  
97      public static <T> Callable<T> callable3(Runnable task, T result)
98      {
99          return null;
100     }
101 
102     public int getBeastNumber()
103     {
104         return 666;
105     }
106     interface IntEnum { // violation ''INTERFACE_DEF' should be separated from previous line.'
107     }
108 
109     class InnerClass {
110 
111         public static final double FOO_PI_INNER = 3.1415;
112 
113         private boolean flagInner = true;
114 
115         {
116             //empty instance initializer
117         }
118 
119         private InnerClass()
120         {
121             //empty
122         }
123     }
124 
125 
126     class SecondInnerClass {
127 
128         private int intVariable;
129     }
130 }
131 
132 class Class22{
133     public int compareTo(InputEmptyLineSeparator aObject) //ok
134     {
135         int number = 0;
136         return 0;
137     }
138 
139     Class2 anon = new Class2(){
140         public int compareTo(InputEmptyLineSeparator aObject) //ok
141         {
142             int number = 0;
143             return 0;
144         }
145     };
146 }
147 
148 class Class32 {
149     int field;
150 }