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;
29 import org.sonar.server.v2.api.rule.ressource.Parameter;
31 @Schema(accessMode = Schema.AccessMode.READ_ONLY)
32 public record RuleRestResponse(
39 RuleTypeRestEnum type,
40 List<RuleImpactRestResponse> impacts,
42 CleanCodeAttributeRestEnum cleanCodeAttribute,
44 CleanCodeAttributeCategoryRestEnum cleanCodeAttributeCategory,
46 RuleStatusRestEnum status,
50 List<RuleDescriptionSectionRestResponse> descriptionSections,
51 @Schema(accessMode = Schema.AccessMode.READ_WRITE)
52 String markdownDescription,
54 String gapDescription,
59 List<String> educationPrinciples,
63 @Schema(accessMode = Schema.AccessMode.READ_WRITE)
65 List<String> systemTags,
70 List<Parameter> parameters,
71 String remediationFunctionType,
72 String remediationFunctionGapMultiplier,
73 String remediationFunctionBaseEffort
77 public static final class Builder {
80 private String repositoryKey;
82 private String severity;
83 private RuleTypeRestEnum type;
84 private List<RuleImpactRestResponse> impacts;
85 private CleanCodeAttributeRestEnum cleanCodeAttribute;
86 private CleanCodeAttributeCategoryRestEnum cleanCodeAttributeCategory;
87 private RuleStatusRestEnum status;
88 private boolean external;
89 private String createdAt;
90 private List<RuleDescriptionSectionRestResponse> descriptionSections;
91 private String markdownDescription;
92 private String gapDescription;
93 private String htmlNote;
94 private String markdownNote;
95 private List<String> educationPrinciples;
96 private boolean template;
97 private String templateId;
98 private List<String> tags;
99 private List<String> systemTags;
100 private String languageKey;
101 private String languageName;
102 private List<Parameter> parameters;
103 private String remediationFunctionType;
104 private String remediationFunctionGapMultiplier;
105 private String remediationFunctionBaseEffort;
110 public static Builder builder() {
111 return new Builder();
114 public Builder setId(String id) {
119 public Builder setKey(String key) {
124 public Builder setRepositoryKey(String repositoryKey) {
125 this.repositoryKey = repositoryKey;
129 public Builder setName(String name) {
134 public Builder setSeverity(@Nullable String severity) {
135 this.severity = severity;
139 public Builder setType(RuleTypeRestEnum type) {
144 public Builder setImpacts(List<RuleImpactRestResponse> impacts) {
145 this.impacts = impacts;
149 public Builder setCleanCodeAttribute(@Nullable CleanCodeAttributeRestEnum cleanCodeAttribute) {
150 this.cleanCodeAttribute = cleanCodeAttribute;
154 public Builder setCleanCodeAttributeCategory(@Nullable CleanCodeAttributeCategoryRestEnum cleanCodeAttributeCategory) {
155 this.cleanCodeAttributeCategory = cleanCodeAttributeCategory;
159 public Builder setStatus(RuleStatusRestEnum status) {
160 this.status = status;
164 public Builder setExternal(boolean external) {
165 this.external = external;
169 public Builder setCreatedAt(@Nullable String createdAt) {
170 this.createdAt = createdAt;
174 public Builder setDescriptionSections(List<RuleDescriptionSectionRestResponse> descriptionSections) {
175 this.descriptionSections = descriptionSections;
179 public Builder setMarkdownDescription(String markdownDescription) {
180 this.markdownDescription = markdownDescription;
184 public Builder setGapDescription(@Nullable String gapDescription) {
185 this.gapDescription = gapDescription;
189 public Builder setHtmlNote(@Nullable String htmlNote) {
190 this.htmlNote = htmlNote;
194 public Builder setMarkdownNote(@Nullable String markdownNote) {
195 this.markdownNote = markdownNote;
199 public Builder setEducationPrinciples(List<String> educationPrinciples) {
200 this.educationPrinciples = educationPrinciples;
204 public Builder setTemplate(boolean template) {
205 this.template = template;
209 public Builder setTemplateId(@Nullable String templateId) {
210 this.templateId = templateId;
214 public Builder setTags(List<String> tags) {
219 public Builder setSystemTags(List<String> systemTags) {
220 this.systemTags = systemTags;
224 public Builder setLanguageKey(@Nullable String languageKey) {
225 this.languageKey = languageKey;
229 public Builder setLanguageName(@Nullable String languageName) {
230 this.languageName = languageName;
234 public Builder setParameters(List<Parameter> parameters) {
235 this.parameters = parameters;
239 public Builder setRemediationFunctionType(@Nullable String remediationFunctionType) {
240 this.remediationFunctionType = remediationFunctionType;
244 public Builder setRemediationFunctionGapMultiplier(@Nullable String remediationFunctionGapMultiplier) {
245 this.remediationFunctionGapMultiplier = remediationFunctionGapMultiplier;
249 public Builder setRemediationFunctionBaseEffort(@Nullable String remediationFunctionBaseEffort) {
250 this.remediationFunctionBaseEffort = remediationFunctionBaseEffort;
254 public RuleRestResponse build() {
255 return new RuleRestResponse(id, key, repositoryKey, name, severity, type, impacts, cleanCodeAttribute, cleanCodeAttributeCategory,
256 status, external, createdAt, descriptionSections, markdownDescription, gapDescription, htmlNote, markdownNote,
257 educationPrinciples, template, templateId, tags, systemTags, languageKey, languageName, parameters, remediationFunctionType,
258 remediationFunctionGapMultiplier, remediationFunctionBaseEffort);