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.internal.testmodules;
21  
22  import java.io.File;
23  import java.util.ArrayList;
24  import java.util.Collections;
25  import java.util.List;
26  
27  import com.puppycrawl.tools.checkstyle.api.AuditListener;
28  import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
29  import com.puppycrawl.tools.checkstyle.api.Configuration;
30  import com.puppycrawl.tools.checkstyle.api.RootModule;
31  
32  public class TestRootModuleChecker implements RootModule {
33      private static boolean processed;
34      private static List<File> filesToCheck;
35      private static Configuration config;
36      private static boolean destroyed;
37      private static String property;
38  
39      @Override
40      public void configure(Configuration configuration) throws CheckstyleException {
41          config = configuration;
42          property = configuration.getAttribute("property");
43      }
44  
45      @Override
46      public void destroy() {
47          destroyed = true;
48      }
49  
50      @Override
51      public int process(List<File> files) throws CheckstyleException {
52          processed = true;
53          filesToCheck = new ArrayList<>(files);
54          return 0;
55      }
56  
57      @Override
58      public void addListener(AuditListener listener) {
59          // not used
60      }
61  
62      @Override
63      public void setModuleClassLoader(ClassLoader moduleClassLoader) {
64          // not used
65      }
66  
67      public static boolean isProcessed() {
68          return processed;
69      }
70  
71      public static boolean isDestroyed() {
72          return destroyed;
73      }
74  
75      public static String getProperty() {
76          return property;
77      }
78  
79      public static void reset() {
80          processed = false;
81          destroyed = false;
82          filesToCheck = null;
83          config = null;
84          property = null;
85      }
86  
87      public static List<File> getFilesToCheck() {
88          return Collections.unmodifiableList(filesToCheck);
89      }
90  
91      public static Configuration getConfig() {
92          return config;
93      }
94  }