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.meta;
21
22 import java.util.ArrayList;
23 import java.util.Collections;
24 import java.util.List;
25
26 /** Simple POJO class for module details. */
27 public final class ModuleDetails {
28 /** List of properties of the module. */
29 private final List<ModulePropertyDetails> properties = new ArrayList<>();
30
31 /** List of violation message keys of the module. */
32 private final List<String> violationMessageKeys = new ArrayList<>();
33
34 /** Name of the module. */
35 private String name;
36
37 /** Fully qualified name of the module. */
38 private String fullQualifiedName;
39
40 /** Parent module. */
41 private String parent;
42
43 /** Description of the module. */
44 private String description;
45
46 /** Type of the module(check/filter/filefilter). */
47 private ModuleType moduleType;
48
49 /** No-argument constructor. */
50 public ModuleDetails() {
51 // empty constructor
52 }
53
54 /**
55 * All-argument constructor.
56 *
57 * @param name name.
58 * @param fullQualifiedName full qualified name.
59 * @param parent parent.
60 * @param description description.
61 * @param moduleType module type.
62 * @param properties properties.
63 * @param violationMessageKeys violation message keys.
64 */
65 public ModuleDetails(String name, String fullQualifiedName, String parent, String description,
66 ModuleType moduleType, List<ModulePropertyDetails> properties,
67 List<String> violationMessageKeys) {
68 this.name = name;
69 this.fullQualifiedName = fullQualifiedName;
70 this.parent = parent;
71 this.description = description;
72 this.moduleType = moduleType;
73 this.properties.addAll(properties);
74 this.violationMessageKeys.addAll(violationMessageKeys);
75 }
76
77 /**
78 * Get name of module.
79 *
80 * @return name of module
81 */
82 public String getName() {
83 return name;
84 }
85
86 /**
87 * Set name of module.
88 *
89 * @param name module name
90 */
91 public void setName(String name) {
92 this.name = name;
93 }
94
95 /**
96 * Get fully qualified name of module.
97 *
98 * @return fully qualified name of module
99 */
100 public String getFullQualifiedName() {
101 return fullQualifiedName;
102 }
103
104 /**
105 * Set fully qualified name of module.
106 *
107 * @param fullQualifiedName fully qualified name of module
108 */
109 public void setFullQualifiedName(String fullQualifiedName) {
110 this.fullQualifiedName = fullQualifiedName;
111 }
112
113 /**
114 * Get parent of module.
115 *
116 * @return parent of module
117 */
118 public String getParent() {
119 return parent;
120 }
121
122 /**
123 * Set parent of module.
124 *
125 * @param parent parent of module
126 */
127 public void setParent(String parent) {
128 this.parent = parent;
129 }
130
131 /**
132 * Get description of module.
133 *
134 * @return description of module
135 */
136 public String getDescription() {
137 return description;
138 }
139
140 /**
141 * Set description of module.
142 *
143 * @param description description of module
144 */
145 public void setDescription(String description) {
146 this.description = description;
147 }
148
149 /**
150 * Get property list of module.
151 *
152 * @return property list of module
153 */
154 public List<ModulePropertyDetails> getProperties() {
155 return Collections.unmodifiableList(properties);
156 }
157
158 /**
159 * Add a single module property to the module's property list and map both.
160 *
161 * @param property module property
162 */
163 public void addToProperties(ModulePropertyDetails property) {
164 properties.add(property);
165 }
166
167 /**
168 * Add a list of properties to the module's property list and map both.
169 *
170 * @param modulePropertyDetailsList list of module property
171 */
172 public void addToProperties(List<ModulePropertyDetails> modulePropertyDetailsList) {
173 properties.addAll(modulePropertyDetailsList);
174 }
175
176 /**
177 * Get violation message keys of the module.
178 *
179 * @return violation message keys of module
180 */
181 public List<String> getViolationMessageKeys() {
182 return Collections.unmodifiableList(violationMessageKeys);
183 }
184
185 /**
186 * Add a key to the violation message key list of the module.
187 *
188 * @param msg violation message key
189 */
190 public void addToViolationMessages(String msg) {
191 violationMessageKeys.add(msg);
192 }
193
194 /**
195 * Add a list of keys to the violation message key list of the module.
196 *
197 * @param msgList a list of violation message keys
198 */
199 public void addToViolationMessages(List<String> msgList) {
200 violationMessageKeys.addAll(msgList);
201 }
202
203 /**
204 * Get module type.
205 *
206 * @return module type
207 */
208 public ModuleType getModuleType() {
209 return moduleType;
210 }
211
212 /**
213 * Set type of module.
214 *
215 * @param moduleType type of module
216 */
217 public void setModuleType(ModuleType moduleType) {
218 this.moduleType = moduleType;
219 }
220 }