View Javadoc
1   package com.google.checkstyle.test.chapter3filestructure.rule341onetoplevel;
2   
3   /** Some javadoc. */
4   public class InputOneTopLevelClassBasic {
5     /** Some javadoc. */
6     public InputOneTopLevelClassBasic() throws CloneNotSupportedException {
7       super.equals(new String());
8       super.clone();
9     }
10  
11    /** Some javadoc. */
12    public Object clone() throws CloneNotSupportedException {
13      return super.clone();
14    }
15  
16    /** Some javadoc. */
17    public void method() throws CloneNotSupportedException {
18      super.clone();
19    }
20  
21    {
22      super.clone();
23    }
24  }
25  
26  // violation below 'Top-level class NoSuperClone has to reside in its own source file.'
27  class NoSuperClone {
28    public Object clone() {
29      return null;
30    }
31  }
32  
33  // violation below 'Top-level class InnerClone has to reside in its own source file.'
34  class InnerClone {
35    public Object clone() {
36      class Inner {
37        public Object clone() throws CloneNotSupportedException {
38          return super.clone();
39        }
40      }
41  
42      return null;
43    }
44  }
45  
46  // This could not pass as valid semantically but tests that
47  // type arguments are ignored when checking super calls
48  // violation below 'Top-level class CloneWithTypeArguments has to reside in its own source file.'
49  class CloneWithTypeArguments {
50    // Some code
51  }
52  
53  // violation below '.* class CloneWithTypeArgumentsAndNoSuper has to reside in .* own source file.'
54  class CloneWithTypeArgumentsAndNoSuper {}
55  
56  // Check that super keyword isn't snagged here
57  // violation below '.* class MyClassWithGenericSuperMethod has to reside in its own source file.'
58  class MyClassWithGenericSuperMethod {
59    void someMethod(java.util.List<? super java.util.Map> l) {
60      // Some code
61    }
62  
63    /**
64     * Not a valid clone override. Should not get flagged.
65     *
66     * @param o some object
67     * @return a cloned Object?
68     */
69    public static Object clone(Object o) {
70      return null;
71    }
72  }
73  
74  // violation below 'Top-level class AnotherClass has to reside in its own source file.'
75  class AnotherClass {
76  
77    /**
78     * Not a valid clone override. Should not get flagged.
79     *
80     * @param t some type
81     * @param <T> a type
82     * @return a cloned type?
83     */
84    public <T> T clone(T t) {
85      return null;
86    }
87  }