001///////////////////////////////////////////////////////////////////////////////////////////////
002// checkstyle: Checks Java source code and other text files for adherence to a set of rules.
003// Copyright (C) 2001-2025 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.site;
021
022import java.util.Collections;
023import java.util.LinkedHashMap;
024import java.util.Map;
025
026import com.puppycrawl.tools.checkstyle.api.DetailNode;
027
028/**
029 * Class with result data of ClassAndPropertiesSettersJavadocScraper.
030 */
031public final class JavadocScraperResultUtil {
032    /**
033     * Map of scraped properties javadocs - name of property, javadoc detail node.
034     */
035    private static final Map<String, DetailNode> PROPERTIES_JAVADOC_NODES =
036            new LinkedHashMap<>();
037
038    /**
039     * The javadoc of class.
040     *
041     * @noinspection - StaticVariableMayNotBeInitialized
042     * @noinspectionreason StaticVariableMayNotBeInitialized -
043     *      no initial initialization value available except null
044     */
045    private static DetailNode moduleJavadocNode;
046
047    /**
048     * Private utility constructor.
049     */
050    private JavadocScraperResultUtil() {
051    }
052
053    /**
054     * Resets the fields.
055     */
056    /* package */ static void clearData() {
057        PROPERTIES_JAVADOC_NODES.clear();
058        moduleJavadocNode = null;
059    }
060
061    /**
062     * Get the properties javadocs map.
063     *
064     * @return the javadocs.
065     */
066    public static Map<String, DetailNode> getPropertiesJavadocNode() {
067        return Collections.unmodifiableMap(PROPERTIES_JAVADOC_NODES);
068    }
069
070    /**
071     * Get the module javadoc.
072     *
073     * @noinspection - StaticVariableUsedBeforeInitialization
074     * @noinspectionreason StaticVariableUsedBeforeInitialization -
075     *      no initial initialization value available
076     * @return the module's javadoc.
077     */
078    public static DetailNode getModuleJavadocNode() {
079        return moduleJavadocNode;
080    }
081
082    /**
083     * Sets the module javadoc.
084     *
085     * @param moduleJavadoc module's javadoc.
086     */
087    /* package */ static void setModuleJavadocNode(DetailNode moduleJavadoc) {
088        moduleJavadocNode = moduleJavadoc;
089    }
090
091    /**
092     * Sets additional property javadoc to property map.
093     *
094     * @param propertyName name of property.
095     * @param propertyJavadoc property's javadoc.
096     */
097    /* package */ static void putPropertyJavadocNode(String propertyName,
098                                                     DetailNode propertyJavadoc) {
099        PROPERTIES_JAVADOC_NODES.put(propertyName, propertyJavadoc);
100    }
101}