aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2014-04-14 15:54:58 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2014-04-14 15:55:18 +0200
commit456a2311733cd6001fb9d8c75261a48b44ddc0e6 (patch)
tree3b8ecefc4c63a7254b27d050c312866fc4a3a447 /sonar-plugin-api
parent43bdbeef3ee0c7c64cd9ec65a46ec08e319cc787 (diff)
downloadsonarqube-456a2311733cd6001fb9d8c75261a48b44ddc0e6.tar.gz
sonarqube-456a2311733cd6001fb9d8c75261a48b44ddc0e6.zip
Fix some quality flaws
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/database/model/ResourceModel.java10
1 files changed, 6 insertions, 4 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/database/model/ResourceModel.java b/sonar-plugin-api/src/main/java/org/sonar/api/database/model/ResourceModel.java
index 27a0323b33c..e40bd0254d8 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/database/model/ResourceModel.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/database/model/ResourceModel.java
@@ -261,19 +261,21 @@ public class ResourceModel extends BaseIdentifiable implements Cloneable {
* @throws IllegalArgumentException if the key is longer than KEY_SIZE
*/
public void setKey(String key) {
+ checkSize(key);
+ this.key = key;
+ }
+
+ private void checkSize(String key) {
if (key.length() > KEY_SIZE) {
throw new IllegalArgumentException("Resource key is too long, max is " + KEY_SIZE + " characters. Got : " + key);
}
- this.key = key;
}
/**
* @throws IllegalArgumentException if the key is longer than KEY_SIZE
*/
public void setDeprecatedKey(String deprecatedKey) {
- if (deprecatedKey.length() > KEY_SIZE) {
- throw new IllegalArgumentException("Resource deprecated key is too long, max is " + KEY_SIZE + " characters. Got : " + deprecatedKey);
- }
+ checkSize(deprecatedKey);
this.deprecatedKey = deprecatedKey;
}