From: Julien Lancelot Date: Fri, 21 Mar 2014 07:33:49 +0000 (+0100) Subject: Move validate() function to the bottom X-Git-Tag: 4.3~331 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2aba814fe362894b38ac191e68d824396de3dfe1;p=sonarqube.git Move validate() function to the bottom --- 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) {