diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2019-06-04 08:24:54 -0500 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2019-07-12 20:21:13 +0200 |
commit | 0f63c1e2bdf0c9fad3ca66ea64ef197bb16e6258 (patch) | |
tree | d173e5f6c3eb6d058e6bce023d74f28c6f7fe0fe /sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java | |
parent | 6eb6107eaaf06d756bf517f0f06cf75021591fa0 (diff) | |
download | sonarqube-0f63c1e2bdf0c9fad3ca66ea64ef197bb16e6258.tar.gz sonarqube-0f63c1e2bdf0c9fad3ca66ea64ef197bb16e6258.zip |
Remove use of Guava in main sources of sonar-plugin-api
Diffstat (limited to 'sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java')
-rw-r--r-- | sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java index f7e199ff592..ca5f062d66e 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java @@ -31,9 +31,8 @@ import org.sonar.api.ce.ComputeEngineSide; import org.sonar.api.scanner.ScannerSide; import org.sonar.api.server.ServerSide; -import static com.google.common.base.MoreObjects.firstNonNull; -import static com.google.common.base.Preconditions.checkArgument; import static org.apache.commons.lang.StringUtils.isNotBlank; +import static org.sonar.api.utils.Preconditions.checkArgument; /** * Used to define a metric in a plugin. Should be used with {@link Metrics} extension point. @@ -219,7 +218,7 @@ public class Metric<G extends Serializable> implements Serializable, org.sonar.a * @param userManaged whether the metric is user managed */ private Metric(String key, String name, String description, ValueType type, Integer direction, Boolean qualitative, @Nullable String domain, - boolean userManaged) { + boolean userManaged) { this.key = key; this.description = description; this.type = type; @@ -739,15 +738,20 @@ public class Metric<G extends Serializable> implements Serializable, org.sonar.a if (ValueType.PERCENT == this.type) { this.bestValue = (direction == DIRECTION_BETTER) ? 100.0 : 0.0; this.worstValue = (direction == DIRECTION_BETTER) ? 0.0 : 100.0; - this.decimalScale = firstNonNull(decimalScale, DEFAULT_DECIMAL_SCALE); + this.decimalScale = coalesce(decimalScale, DEFAULT_DECIMAL_SCALE); } else if (ValueType.FLOAT == this.type) { - this.decimalScale = firstNonNull(decimalScale, DEFAULT_DECIMAL_SCALE); + this.decimalScale = coalesce(decimalScale, DEFAULT_DECIMAL_SCALE); } return new Metric<>(this); } } + @CheckForNull + private static <T> T coalesce(@Nullable T a, @Nullable T b) { + return a == null ? b : a; + } + @Override public String key() { return getKey(); |