View Javadoc
1   ///////////////////////////////////////////////////////////////////////////////////////////////
2   // checkstyle: Checks Java source code and other text files for adherence to a set of rules.
3   // Copyright (C) 2001-2025 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.site;
21  
22  import java.util.Collections;
23  import java.util.LinkedHashMap;
24  import java.util.Map;
25  
26  import com.puppycrawl.tools.checkstyle.api.DetailNode;
27  
28  /**
29   * Class with result data of ClassAndPropertiesSettersJavadocScraper.
30   */
31  public final class JavadocScraperResultUtil {
32      /**
33       * Map of scraped properties javadocs - name of property, javadoc detail node.
34       */
35      private static final Map<String, DetailNode> PROPERTIES_JAVADOC_NODES =
36              new LinkedHashMap<>();
37  
38      /**
39       * The javadoc of class.
40       *
41       * @noinspection - StaticVariableMayNotBeInitialized
42       * @noinspectionreason StaticVariableMayNotBeInitialized -
43       *      no initial initialization value available except null
44       */
45      private static DetailNode moduleJavadocNode;
46  
47      /**
48       * Private utility constructor.
49       */
50      private JavadocScraperResultUtil() {
51      }
52  
53      /**
54       * Resets the fields.
55       */
56      /* package */ static void clearData() {
57          PROPERTIES_JAVADOC_NODES.clear();
58          moduleJavadocNode = null;
59      }
60  
61      /**
62       * Get the properties javadocs map.
63       *
64       * @return the javadocs.
65       */
66      public static Map<String, DetailNode> getPropertiesJavadocNode() {
67          return Collections.unmodifiableMap(PROPERTIES_JAVADOC_NODES);
68      }
69  
70      /**
71       * Get the module javadoc.
72       *
73       * @noinspection - StaticVariableUsedBeforeInitialization
74       * @noinspectionreason StaticVariableUsedBeforeInitialization -
75       *      no initial initialization value available
76       * @return the module's javadoc.
77       */
78      public static DetailNode getModuleJavadocNode() {
79          return moduleJavadocNode;
80      }
81  
82      /**
83       * Sets the module javadoc.
84       *
85       * @param moduleJavadoc module's javadoc.
86       */
87      /* package */ static void setModuleJavadocNode(DetailNode moduleJavadoc) {
88          moduleJavadocNode = moduleJavadoc;
89      }
90  
91      /**
92       * Sets additional property javadoc to property map.
93       *
94       * @param propertyName name of property.
95       * @param propertyJavadoc property's javadoc.
96       */
97      /* package */ static void putPropertyJavadocNode(String propertyName,
98                                                       DetailNode propertyJavadoc) {
99          PROPERTIES_JAVADOC_NODES.put(propertyName, propertyJavadoc);
100     }
101 }