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   @TestClassAnnotation2
9   class InputFormattedLeftCurlyAnnotations {
10    private static final int X = 10;
11  
12    @Override
13    public boolean equals(Object other) {
14      return false;
15    }
16  
17    @Override
18    @SuppressWarnings("unused")
19    public int hashCode() {
20      int a = 10;
21      return 1;
22    }
23  
24    @Override
25    @SuppressWarnings({"unused", "unchecked", "static-access"})
26    public String toString() {
27      Integer i = this.X;
28      List<String> l = new ArrayList();
29      return "SomeString";
30    }
31  }
32  
33  // violation below '.* InputFormattedLeftCurlyAnnotations2 has to reside in its own source file.'
34  @TestClassAnnotation2
35  class InputFormattedLeftCurlyAnnotations2 {
36    private static final int X = 10;
37  
38    @Override
39    public boolean equals(Object other) {
40      return false;
41    }
42  
43    @Override
44    @SuppressWarnings("unused")
45    public int hashCode() {
46      int a = 10;
47      return 1;
48    }
49  
50    @Override
51    @SuppressWarnings({"unused", "unchecked", "static-access"})
52    public String toString() {
53      Integer i = this.X;
54      List<String> l = new ArrayList();
55      return "SomeString";
56    }
57  }
58  
59  // violation below 'Top-level class TestClassAnnotation2 has to reside in its own source file.'
60  @Target(ElementType.TYPE)
61  @interface TestClassAnnotation2 {}