001///////////////////////////////////////////////////////////////////////////////////////////////
002// checkstyle: Checks Java source code and other text files for adherence to a set of rules.
003// Copyright (C) 2001-2024 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.util.Set;
023
024import com.puppycrawl.tools.checkstyle.Checker;
025
026/**
027 * The following interface should be implemented by each module (inheritor of
028 * {@link AbstractCheck}, implementor of {@link FileSetCheck}, or {@link Filter}) which uses
029 * external resources of any kind for its configuration. Such modules must declare external
030 * resource locations as a set of {@link String} which will be returned from
031 * {@link #getExternalResourceLocations}. This allows Checkstyle to invalidate (clear) cache
032 * when the content of at least one external configuration resource of the module is changed.
033 *
034 */
035@FunctionalInterface
036public interface ExternalResourceHolder {
037
038    /**
039     * Returns a set of external configuration resource locations which are used by the module.
040     * ATTENTION!
041     * If 'getExternalResourceLocations()' return null, there will be
042     * {@link NullPointerException} in {@link Checker}.
043     * Such behaviour will signal that your module (check or filter) is designed incorrectly.
044     * It makes sense to return an empty set from 'getExternalResourceLocations()'
045     * only for composite modules like {@link com.puppycrawl.tools.checkstyle.TreeWalker}.
046     *
047     * @return a set of external configuration resource locations which are used by the module.
048     */
049    Set<String> getExternalResourceLocations();
050
051}