001////////////////////////////////////////////////////////////////////////////////
002// checkstyle: Checks Java source code for adherence to a set of rules.
003// Copyright (C) 2001-2021 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.meta;
021
022import java.util.ArrayList;
023import java.util.Collections;
024import java.util.List;
025
026/** Simple POJO class for module details. */
027public final class ModuleDetails {
028
029    /** List of properties of the module. */
030    private final List<ModulePropertyDetails> properties = new ArrayList<>();
031
032    /** List of violation message keys of the module. */
033    private final List<String> violationMessageKeys = new ArrayList<>();
034
035    /** Name of the module. */
036    private String name;
037
038    /** Fully qualified name of the module. */
039    private String fullQualifiedName;
040
041    /** Parent module. */
042    private String parent;
043
044    /** Description of the module. */
045    private String description;
046
047    /** Type of the module(check/filter/filefilter). */
048    private ModuleType moduleType;
049
050    /**
051     * Get name of module.
052     *
053     * @return name of module
054     */
055    public String getName() {
056        return name;
057    }
058
059    /**
060     * Set name of module.
061     *
062     * @param name module name
063     */
064    public void setName(String name) {
065        this.name = name;
066    }
067
068    /**
069     * Get fully qualified name of module.
070     *
071     * @return fully qualified name of module
072     */
073    public String getFullQualifiedName() {
074        return fullQualifiedName;
075    }
076
077    /**
078     * Set fully qualified name of module.
079     *
080     * @param fullQualifiedName fully qualified name of module
081     */
082    public void setFullQualifiedName(String fullQualifiedName) {
083        this.fullQualifiedName = fullQualifiedName;
084    }
085
086    /**
087     * Get parent of module.
088     *
089     * @return parent of module
090     */
091    public String getParent() {
092        return parent;
093    }
094
095    /**
096     * Set parent of module.
097     *
098     * @param parent parent of module
099     */
100    public void setParent(String parent) {
101        this.parent = parent;
102    }
103
104    /**
105     * Get description of module.
106     *
107     * @return description of module
108     */
109    public String getDescription() {
110        return description;
111    }
112
113    /**
114     * Set description of module.
115     *
116     * @param description description of module
117     */
118    public void setDescription(String description) {
119        this.description = description;
120    }
121
122    /**
123     * Get property list of module.
124     *
125     * @return property list of module
126     */
127    public List<ModulePropertyDetails> getProperties() {
128        return Collections.unmodifiableList(properties);
129    }
130
131    /**
132     * Add a single module property to the module's property list and map both.
133     *
134     * @param property module property
135     */
136    public void addToProperties(ModulePropertyDetails property) {
137        properties.add(property);
138    }
139
140    /**
141     * Add a list of properties to the module's property list and map both.
142     *
143     * @param modulePropertyDetailsList list of module property
144     */
145    public void addToProperties(List<ModulePropertyDetails> modulePropertyDetailsList) {
146        properties.addAll(modulePropertyDetailsList);
147    }
148
149    /**
150     * Get violation message keys of the module.
151     *
152     * @return violation message keys of module
153     */
154    public List<String> getViolationMessageKeys() {
155        return Collections.unmodifiableList(violationMessageKeys);
156    }
157
158    /**
159     * Add a key to the violation message key list of the module.
160     *
161     * @param msg violation message key
162     */
163    public void addToViolationMessages(String msg) {
164        violationMessageKeys.add(msg);
165    }
166
167    /**
168     * Add a list of keys to the violation message key list of the module.
169     *
170     * @param msgList a list of violation message keys
171     */
172    public void addToViolationMessages(List<String> msgList) {
173        violationMessageKeys.addAll(msgList);
174    }
175
176    /**
177     * Get module type.
178     *
179     * @return module type
180     */
181    public ModuleType getModuleType() {
182        return moduleType;
183    }
184
185    /**
186     * Set type of module.
187     *
188     * @param moduleType type of module
189     */
190    public void setModuleType(ModuleType moduleType) {
191        this.moduleType = moduleType;
192    }
193}