View Javadoc
1   ////////////////////////////////////////////////////////////////////////////////
2   // checkstyle: Checks Java source code for adherence to a set of rules.
3   // Copyright (C) 2001-2017 the original author or authors.
4   //
5   // This library is free software; you can redistribute it and/or
6   // modify it under the terms of the GNU Lesser General Public
7   // License as published by the Free Software Foundation; either
8   // version 2.1 of the License, or (at your option) any later version.
9   //
10  // This library is distributed in the hope that it will be useful,
11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  // Lesser General Public License for more details.
14  //
15  // You should have received a copy of the GNU Lesser General Public
16  // License along with this library; if not, write to the Free Software
17  // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  ////////////////////////////////////////////////////////////////////////////////
19  
20  package com.puppycrawl.tools.checkstyle.checks.whitespace.emptylineseparator; //no violation: trainling comment
21  import java.io.Serializable;
22  import java.util.ArrayList; /*no violation: trailing comment*/
23  import java.util.HashMap;
24  import java.util.List;
25  import java.util.Map;
26  import java.util.concurrent.Callable;
27  import java.util.Collections;
28  /* no violation: block comment after token*/
29  
30  import com.oracle.net.Sdp;
31  //no violation: single line comment after token
32  
33  import javax.swing.AbstractAction; /* no violation: no trailing comment
34  */
35  
36  import org.apache.commons.beanutils.locale.converters.ByteLocaleConverter;
37  import org.apache.commons.beanutils.BasicDynaBean;
38  class InputEmptyLineSeparator
39  {
40      public static final double FOO_PI = 3.1415;
41      private boolean flag = true; 
42      static {
43          //empty static initializer
44      }
45      // no blank line - fail
46      {
47          //empty instance initializer
48      }
49  
50      // one blank line - ok
51      {
52          //empty instance initializer
53      }
54      // no blank line - fail
55      /**
56       * 
57       * 
58       * 
59       */
60      private InputEmptyLineSeparator()
61      {
62          //empty
63      }
64      //separator blank line
65      public int compareTo(Object aObject)
66      {
67          int number = 0;
68          return 0;
69      }
70  
71      public int compareTo2(Object aObject) // empty line - ok
72      {
73          int number = 0;
74          return 0;
75      }
76      /**
77       * No blank line between methods - fail
78       * @param task
79       * @param result
80       * @return
81       */
82      public static <T> Callable<T> callable(Runnable task, T result)
83      {
84          return null;
85      }
86  
87      /**
88       * Blank line before Javadoc - ok
89       * @param task
90       * @param result
91       * @return
92       */
93      public static <T> Callable<T> callable2(Runnable task, T result)
94      {
95          return null;
96      }
97      /**
98       * Blank line after Javadoc - ok
99       * @param task
100      * @param result
101      * @return
102      */
103     
104     public static <T> Callable<T> callable3(Runnable task, T result)
105     {
106         return null;
107     }
108 
109     public int getBeastNumber()
110     {
111         return 666;
112     }
113     interface IntEnum {
114     }
115 
116     class InnerClass {
117         
118         public static final double FOO_PI_INNER = 3.1415;
119 
120         private boolean flagInner = true; 
121 
122         {
123             //empty instance initializer
124         }
125 
126         private InnerClass()
127         {
128             //empty
129         }
130     }
131 
132 
133     class SecondInnerClass {
134 
135         private int intVariable;
136     }
137 }
138 
139 class Class2{
140     public int compareTo(InputEmptyLineSeparator aObject) //ok
141     {
142         int number = 0;
143         return 0;
144     }
145     
146     Class2 anon = new Class2(){
147         public int compareTo(InputEmptyLineSeparator aObject) //ok
148         {
149             int number = 0;
150             return 0;
151         }
152     };
153 }