001 /*
002 * SonarQube, open source software quality management tool.
003 * Copyright (C) 2008-2014 SonarSource
004 * mailto:contact AT sonarsource DOT com
005 *
006 * SonarQube is free software; you can redistribute it and/or
007 * modify it under the terms of the GNU Lesser General Public
008 * License as published by the Free Software Foundation; either
009 * version 3 of the License, or (at your option) any later version.
010 *
011 * SonarQube is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014 * Lesser General Public License for more details.
015 *
016 * You should have received a copy of the GNU Lesser General Public License
017 * along with this program; if not, write to the Free Software Foundation,
018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
019 */
020 package org.sonar.wsclient.services;
021
022 import javax.annotation.CheckForNull;
023 import javax.annotation.Nullable;
024
025 import java.util.Date;
026
027 /**
028 * @deprecated in 3.6. Replaced by issues.
029 */
030 @Deprecated
031 public class Violation extends Model {
032
033 private String message = null;
034 private String severity = null;
035 private Integer line = null;
036 private String ruleKey = null;
037 private String ruleName = null;
038 private String resourceKey = null;
039 private String resourceName = null;
040 private String resourceQualifier = null;
041 private Date createdAt = null;
042 private boolean switchedOff;
043
044 @CheckForNull
045 public String getMessage() {
046 return message;
047 }
048
049 public void setMessage(@Nullable String message) {
050 this.message = message;
051 }
052
053 /**
054 * @since 2.5
055 */
056 @CheckForNull
057 public String getSeverity() {
058 return severity;
059 }
060
061 /**
062 * @since 2.5
063 */
064 public void setSeverity(@Nullable String severity) {
065 this.severity = severity;
066 }
067
068 /**
069 * @deprecated since 2.5 use {@link #getSeverity()} instead. See http://jira.codehaus.org/browse/SONAR-1829
070 */
071 @Deprecated
072 public String getPriority() {
073 return severity;
074 }
075
076 /**
077 * @deprecated since 2.5 use {@link #setSeverity(String)} instead. See http://jira.codehaus.org/browse/SONAR-1829
078 */
079 @Deprecated
080 public void setPriority(String priority) {
081 this.severity = priority;
082 }
083
084 /**
085 * @return line number (numeration starts from 1), or <code>null</code> if violation doesn't belong to concrete line
086 * @see #hasLine()
087 */
088 @CheckForNull
089 public Integer getLine() {
090 return line;
091 }
092
093 public void setLine(@Nullable Integer line) {
094 if (line != null && line < 1) {
095 /*
096 * This shouldn't happen, however line would be normalized to null if web service returns incorrect value (less than 1) in compliance
097 * with a contract for getLine method. Normalization added in 2.8 - see http://jira.codehaus.org/browse/SONAR-2386
098 */
099 this.line = null;
100 } else {
101 this.line = line;
102 }
103 }
104
105 /**
106 * @return <code>true<code> if violation belongs to concrete line
107 * @since 2.8
108 */
109 public boolean hasLine() {
110 return line != null;
111 }
112
113 @Nullable
114 public String getResourceKey() {
115 return resourceKey;
116 }
117
118 public void setResourceKey(@Nullable String resourceKey) {
119 this.resourceKey = resourceKey;
120 }
121
122 @CheckForNull
123 public String getRuleKey() {
124 return ruleKey;
125 }
126
127 public Violation setRuleKey(@Nullable String s) {
128 this.ruleKey = s;
129 return this;
130 }
131
132 @CheckForNull
133 public String getRuleName() {
134 return ruleName;
135 }
136
137 public Violation setRuleName(@Nullable String ruleName) {
138 this.ruleName = ruleName;
139 return this;
140 }
141
142 @CheckForNull
143 public String getResourceName() {
144 return resourceName;
145 }
146
147 public Violation setResourceName(@Nullable String resourceName) {
148 this.resourceName = resourceName;
149 return this;
150 }
151
152 @CheckForNull
153 public String getResourceQualifier() {
154 return resourceQualifier;
155 }
156
157 public Violation setResourceQualifier(@Nullable String resourceQualifier) {
158 this.resourceQualifier = resourceQualifier;
159 return this;
160 }
161
162 /**
163 * @since 2.5
164 */
165 @CheckForNull
166 public Date getCreatedAt() {
167 return createdAt;
168 }
169
170 /**
171 * @since 2.5
172 */
173 public Violation setCreatedAt(@Nullable Date createdAt) {
174 this.createdAt = createdAt;
175 return this;
176 }
177
178 /**
179 * @since 2.5
180 */
181 public boolean isCreatedAfter(Date date) {
182 return createdAt != null && date != null && createdAt.after(date);
183 }
184
185 /**
186 * @since 2.8
187 */
188 public Violation setSwitchedOff(@Nullable Boolean b) {
189 this.switchedOff = (b != null && b);
190 return this;
191 }
192
193 /**
194 * @since 2.8
195 */
196 @Nullable
197 public boolean isSwitchedOff() {
198 return switchedOff;
199 }
200
201 }