aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2014-03-21 08:33:49 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2014-03-21 08:33:49 +0100
commit2aba814fe362894b38ac191e68d824396de3dfe1 (patch)
tree44b90406d5febafd823b17867f59c0479bfe9e63 /sonar-plugin-api
parentd4222ae08975807f42dcba1afa7a7015d9bc89c9 (diff)
downloadsonarqube-2aba814fe362894b38ac191e68d824396de3dfe1.tar.gz
sonarqube-2aba814fe362894b38ac191e68d824396de3dfe1.zip
Move validate() function to the bottom
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/server/rule/DebtRemediationFunction.java44
1 files changed, 22 insertions, 22 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/DebtRemediationFunction.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/DebtRemediationFunction.java
index 476fe769849..d355dbf5fee 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/DebtRemediationFunction.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/DebtRemediationFunction.java
@@ -56,28 +56,6 @@ public class DebtRemediationFunction {
validate();
}
- private void validate(){
- switch (type) {
- case LINEAR:
- if (this.factor == null || this.offset != null) {
- throw new ValidationException(String.format("%s is invalid, Linear remediation function should only define a factor", this));
- }
- break;
- case LINEAR_OFFSET:
- if (this.factor == null || this.offset == null) {
- throw new ValidationException(String.format("%s is invalid, Linear with offset remediation function should define both factor and offset", this));
- }
- break;
- case CONSTANT_ISSUE:
- if (this.factor != null || this.offset == null) {
- throw new ValidationException(String.format("%s is invalid, Constant/issue remediation function should only define an offset", this));
- }
- break;
- default:
- throw new IllegalStateException(String.format("Remediation function of %s is unknown", this));
- }
- }
-
public static DebtRemediationFunction create(Type type, @Nullable String factor, @Nullable String offset) {
return new DebtRemediationFunction(type, factor, offset);
}
@@ -108,6 +86,28 @@ public class DebtRemediationFunction {
return offset;
}
+ private void validate(){
+ switch (type) {
+ case LINEAR:
+ if (this.factor == null || this.offset != null) {
+ throw new ValidationException(String.format("%s is invalid, Linear remediation function should only define a factor", this));
+ }
+ break;
+ case LINEAR_OFFSET:
+ if (this.factor == null || this.offset == null) {
+ throw new ValidationException(String.format("%s is invalid, Linear with offset remediation function should define both factor and offset", this));
+ }
+ break;
+ case CONSTANT_ISSUE:
+ if (this.factor != null || this.offset == null) {
+ throw new ValidationException(String.format("%s is invalid, Constant/issue remediation function should only define an offset", this));
+ }
+ break;
+ default:
+ throw new IllegalStateException(String.format("Remediation function of %s is unknown", this));
+ }
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) {