View Javadoc
1   /*
2   RedundantImport
3   
4   
5   */
6   
7   package com.puppycrawl.tools.checkstyle.checks.imports.redundantimport;
8   
9   import com.puppycrawl.tools.checkstyle.checks.imports.redundantimport.*; // violation 'Redundant import from the same package'
10  import com.puppycrawl.tools.checkstyle.checks.imports.redundantimport.InputRedundantImportBug; // violation 'Redundant import from the same package'
11  import java.io.*;
12  import java.lang.*; // violation 'Redundant import from the java.lang package'
13  import java.lang.String; // violation 'Redundant import from the java.lang package'
14  
15  import java.util.List;
16  import java.util.List; // violation 'Duplicate import to line 15'
17  import java.util.Iterator;
18  import java.util.Enumeration;
19  import java.util.Arrays;
20  
21  import javax.swing.JToolBar;
22  import javax.swing.JToggleButton;
23  import javax.swing.ScrollPaneLayout;
24  import javax.swing.BorderFactory;
25  import static java.io.File.listRoots;
26  
27  import static javax.swing.WindowConstants.*;
28  import static javax.swing.WindowConstants.*; // violation 'Duplicate import to line 27'
29  import static java.io.File.createTempFile;
30  import static java.io.File.pathSeparator;
31  
32  import java.awt.Component;
33  import java.awt.Graphics2D;
34  import java.awt.HeadlessException;
35  import java.awt.Label;
36  import java.util.Date;
37  import java.util.Calendar;
38  import java.util.BitSet;
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  import static java.lang.Math.PI;
49  import static com.puppycrawl.tools.checkstyle.checks.imports.RedundantImportCheck.MSG_SAME;
50  
51  /**
52   * Test case for imports
53   * Here's an import used only by javadoc: {@link Date}.
54   * @author Oliver Burn
55   * @author lkuehne
56   * @author Michael Studman
57   * @see Calendar Should avoid unused import for Calendar
58   **/
59  class InputRedundantImportWithChecker
60  {
61      /** ignore **/
62      private Class mUse1 = null;
63      /** ignore **/
64      private Class mUse2 = java.io.File.class;
65      /** ignore **/
66      private Class mUse3 = Iterator[].class;
67      /** ignore **/
68      private Class mUse4 = java.util.Enumeration[].class;
69      /** usage of illegal import **/
70      private String ftpClient = null;
71  
72      /** usage via static method, both normal and fully qualified */
73      {
74          int[] x = {};
75          Arrays.sort(x);
76          Object obj = javax.swing.BorderFactory.createEmptyBorder();
77          File[] files = listRoots();
78      }
79  
80      /** usage of inner class as type */
81      private JToolBar.Separator mSep = null;
82  
83      /** usage of inner class in Constructor */
84      private Object mUse5 = new Object();
85  
86      /** usage of inner class in constructor, fully qualified */
87      private Object mUse6 = new javax.swing.JToggleButton.ToggleButtonModel();
88  
89      /** we use class name as member's name.
90       *  also an inline JavaDoc-only import {@link Vector linkText} */
91      private int Component;
92  
93      /**
94       * method comment with JavaDoc-only import {@link BitSet#aMethod()}
95       */
96      public void Label() {}
97  
98      /**
99       * Renders to a {@linkplain Graphics2D graphics context}.
100      * @throws HeadlessException if no graphis environment can be found.
101      * @exception HeadlessException if no graphis environment can be found.
102      */
103     public void render() {}
104 
105     /**
106      * First is a class with a method with arguments {@link TestClass1#method1(TestClass2)}.
107      * Next is a class with typed method {@link TestClass3#method2(TestClass4, TestClass5)}.
108      *
109      * @param param1 with a link {@link TestClass6}
110      * @throws TestClass7 when broken
111      * @deprecated in 1 for removal in 2. Use {@link TestClass8}
112      */
113     public void aMethodWithManyLinks() {}
114 }