3 * Copyright (C) 2009-2023 SonarSource SA
4 * mailto:info AT sonarsource DOT com
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 package org.sonar.server.v2.api.rule.response;
22 import io.swagger.v3.oas.annotations.media.Schema;
23 import java.util.List;
24 import javax.annotation.Nullable;
25 import org.sonar.server.v2.api.rule.enums.CleanCodeAttributeCategoryRestEnum;
26 import org.sonar.server.v2.api.rule.enums.CleanCodeAttributeRestEnum;
27 import org.sonar.server.v2.api.rule.enums.RuleStatusRestEnum;
28 import org.sonar.server.v2.api.rule.enums.RuleTypeRestEnum;
30 @Schema(accessMode = Schema.AccessMode.READ_ONLY)
31 public record RuleRestResponse(
38 RuleTypeRestEnum type,
39 List<RuleImpactRestResponse> impacts,
41 CleanCodeAttributeRestEnum cleanCodeAttribute,
43 CleanCodeAttributeCategoryRestEnum cleanCodeAttributeCategory,
45 RuleStatusRestEnum status,
49 List<RuleDescriptionSectionRestResponse> descriptionSections,
50 @Schema(accessMode = Schema.AccessMode.READ_WRITE)
51 String markdownDescription,
53 String gapDescription,
58 List<String> educationPrinciples,
62 @Schema(accessMode = Schema.AccessMode.READ_WRITE)
64 List<String> systemTags,
69 List<RuleParameterRestResponse> parameters,
70 String remediationFunctionType,
71 String remediationFunctionGapMultiplier,
72 String remediationFunctionBaseEffort
76 public static final class Builder {
79 private String repositoryKey;
81 private String severity;
82 private RuleTypeRestEnum type;
83 private List<RuleImpactRestResponse> impacts;
84 private CleanCodeAttributeRestEnum cleanCodeAttribute;
85 private CleanCodeAttributeCategoryRestEnum cleanCodeAttributeCategory;
86 private RuleStatusRestEnum status;
87 private boolean external;
88 private String createdAt;
89 private List<RuleDescriptionSectionRestResponse> descriptionSections;
90 private String markdownDescription;
91 private String gapDescription;
92 private String htmlNote;
93 private String markdownNote;
94 private List<String> educationPrinciples;
95 private boolean template;
96 private String templateId;
97 private List<String> tags;
98 private List<String> systemTags;
99 private String languageKey;
100 private String languageName;
101 private List<RuleParameterRestResponse> parameters;
102 private String remediationFunctionType;
103 private String remediationFunctionGapMultiplier;
104 private String remediationFunctionBaseEffort;
109 public static Builder builder() {
110 return new Builder();
113 public Builder setId(String id) {
118 public Builder setKey(String key) {
123 public Builder setRepositoryKey(String repositoryKey) {
124 this.repositoryKey = repositoryKey;
128 public Builder setName(String name) {
133 public Builder setSeverity(@Nullable String severity) {
134 this.severity = severity;
138 public Builder setType(RuleTypeRestEnum type) {
143 public Builder setImpacts(List<RuleImpactRestResponse> impacts) {
144 this.impacts = impacts;
148 public Builder setCleanCodeAttribute(@Nullable CleanCodeAttributeRestEnum cleanCodeAttribute) {
149 this.cleanCodeAttribute = cleanCodeAttribute;
153 public Builder setCleanCodeAttributeCategory(@Nullable CleanCodeAttributeCategoryRestEnum cleanCodeAttributeCategory) {
154 this.cleanCodeAttributeCategory = cleanCodeAttributeCategory;
158 public Builder setStatus(RuleStatusRestEnum status) {
159 this.status = status;
163 public Builder setExternal(boolean external) {
164 this.external = external;
168 public Builder setCreatedAt(@Nullable String createdAt) {
169 this.createdAt = createdAt;
173 public Builder setDescriptionSections(List<RuleDescriptionSectionRestResponse> descriptionSections) {
174 this.descriptionSections = descriptionSections;
178 public Builder setMarkdownDescription(String markdownDescription) {
179 this.markdownDescription = markdownDescription;
183 public Builder setGapDescription(@Nullable String gapDescription) {
184 this.gapDescription = gapDescription;
188 public Builder setHtmlNote(@Nullable String htmlNote) {
189 this.htmlNote = htmlNote;
193 public Builder setMarkdownNote(@Nullable String markdownNote) {
194 this.markdownNote = markdownNote;
198 public Builder setEducationPrinciples(List<String> educationPrinciples) {
199 this.educationPrinciples = educationPrinciples;
203 public Builder setTemplate(boolean template) {
204 this.template = template;
208 public Builder setTemplateId(@Nullable String templateId) {
209 this.templateId = templateId;
213 public Builder setTags(List<String> tags) {
218 public Builder setSystemTags(List<String> systemTags) {
219 this.systemTags = systemTags;
223 public Builder setLanguageKey(@Nullable String languageKey) {
224 this.languageKey = languageKey;
228 public Builder setLanguageName(@Nullable String languageName) {
229 this.languageName = languageName;
233 public Builder setParameters(List<RuleParameterRestResponse> parameters) {
234 this.parameters = parameters;
238 public Builder setRemediationFunctionType(@Nullable String remediationFunctionType) {
239 this.remediationFunctionType = remediationFunctionType;
243 public Builder setRemediationFunctionGapMultiplier(@Nullable String remediationFunctionGapMultiplier) {
244 this.remediationFunctionGapMultiplier = remediationFunctionGapMultiplier;
248 public Builder setRemediationFunctionBaseEffort(@Nullable String remediationFunctionBaseEffort) {
249 this.remediationFunctionBaseEffort = remediationFunctionBaseEffort;
253 public RuleRestResponse build() {
254 return new RuleRestResponse(id, key, repositoryKey, name, severity, type, impacts, cleanCodeAttribute, cleanCodeAttributeCategory,
255 status, external, createdAt, descriptionSections, markdownDescription, gapDescription, htmlNote, markdownNote,
256 educationPrinciples, template, templateId, tags, systemTags, languageKey, languageName, parameters, remediationFunctionType,
257 remediationFunctionGapMultiplier, remediationFunctionBaseEffort);