View Javadoc
1   package com.google.checkstyle.test.chapter4formatting.rule412nonemptyblocks;
2   
3   import java.lang.annotation.ElementType;
4   import java.lang.annotation.Target;
5   import java.util.ArrayList;
6   import java.util.List;
7   
8   @TestClassAnnotation
9   class InputLeftCurlyAnnotations
10    { // violation ''{' at column 3 should be on the previous line.'
11      private static final int X = 10;
12  
13      @Override
14      public boolean equals(
15          Object other)
16      { // violation ''{' at column 5 should be on the previous line.'
17        return false;
18      }
19  
20      @Override
21      @SuppressWarnings("unused")
22      public int hashCode()
23      { // violation ''{' at column 5 should be on the previous line.'
24        int a = 10;
25        return 1;
26      }
27  
28      @Override
29      @SuppressWarnings({"unused", "unchecked", "static-access"})
30      public String toString()
31      { // violation ''{' at column 5 should be on the previous line.'
32        Integer i = this.X;
33        List<String> l = new ArrayList();
34        return "SomeString";
35      }
36    }
37  
38  // violation below '.* InputLeftCurlyAnnotations2 has to reside in its own source file.'
39  @TestClassAnnotation
40  class InputLeftCurlyAnnotations2 {
41    private static final int X = 10;
42  
43    @Override
44    public boolean equals(Object other) {
45      return false;
46    }
47  
48    @Override
49    @SuppressWarnings("unused")
50    public int hashCode() {
51      int a = 10;
52      return 1;
53    }
54  
55    @Override
56    @SuppressWarnings({"unused", "unchecked", "static-access"})
57    public String toString()
58      { // violation ''{' at column 5 should be on the previous line.'
59        Integer i = this.X;
60        List<String> l = new ArrayList();
61        return "SomeString";
62      }
63  }
64  
65  // violation below 'Top-level class TestClassAnnotation has to reside in its own source file.'
66  @Target(ElementType.TYPE)
67  @interface TestClassAnnotation {}