001///////////////////////////////////////////////////////////////////////////////////////////////
002// checkstyle: Checks Java source code and other text files for adherence to a set of rules.
003// Copyright (C) 2001-2026 the original author or authors.
004//
005// This library is free software; you can redistribute it and/or
006// modify it under the terms of the GNU Lesser General Public
007// License as published by the Free Software Foundation; either
008// version 2.1 of the License, or (at your option) any later version.
009//
010// This library is distributed in the hope that it will be useful,
011// but WITHOUT ANY WARRANTY; without even the implied warranty of
012// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013// Lesser General Public License for more details.
014//
015// You should have received a copy of the GNU Lesser General Public
016// License along with this library; if not, write to the Free Software
017// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
018///////////////////////////////////////////////////////////////////////////////////////////////
019
020package com.puppycrawl.tools.checkstyle.api;
021
022import java.io.File;
023import java.util.List;
024
025/**
026 * The first module that is run as part of Checkstyle and controls its entire behavior and children.
027 */
028public interface RootModule extends Configurable {
029
030    /** Cleans up the object. */
031    void destroy();
032
033    /**
034     * Processes a set of files.
035     * Once this is done, it is highly recommended to call for
036     * the destroy method to close and remove the listeners.
037     *
038     * @param files the list of files to be audited.
039     * @return the total number of audit events with error severity found
040     * @throws CheckstyleException if error condition within Checkstyle occurs
041     * @see #destroy()
042     */
043    int process(List<File> files) throws CheckstyleException;
044
045    /**
046     * Add the listener that will be used to receive events from the audit.
047     *
048     * @param listener the nosy thing
049     */
050    void addListener(AuditListener listener);
051
052    /**
053     * Sets the classloader used to load Checkstyle core and custom module
054     * classes when the module tree is being built up.
055     * If no custom ModuleFactory is being set for the root module then
056     * this module classloader must be specified.
057     *
058     * @param moduleClassLoader the classloader used to load module classes
059     */
060    void setModuleClassLoader(ClassLoader moduleClassLoader);
061
062}