org.sonar.api.measures.Metric.getDecimalScale()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(3.3k)|赞(0)|评价(0)|浏览(130)

本文整理了Java中org.sonar.api.measures.Metric.getDecimalScale()方法的一些代码示例,展示了Metric.getDecimalScale()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Metric.getDecimalScale()方法的具体详情如下:
包路径:org.sonar.api.measures.Metric
类名称:Metric
方法名:getDecimalScale

Metric.getDecimalScale介绍

[英]Return the number scale if metric type is ValueType#FLOAT, else null
[中]如果度量类型为ValueType#FLOAT,则返回数字刻度,否则返回null

代码示例

代码示例来源:origin: SonarSource/sonarqube

@Test
public void default_decimal_scale_is_1() {
 Metric metric = new Metric.Builder("foo", "Foo", Metric.ValueType.FLOAT)
  .create();
 assertThat(metric.getDecimalScale()).isEqualTo(1);
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void override_decimal_scale_of_float_metric() {
 Metric metric = new Metric.Builder("foo", "Foo", Metric.ValueType.FLOAT)
  .setDecimalScale(3)
  .create();
 assertThat(metric.getDecimalScale()).isEqualTo(3);
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void override_decimal_scale_of_percent_metric() {
 Metric metric = new Metric.Builder("foo", "Foo", Metric.ValueType.PERCENT)
  .setDecimalScale(3)
  .create();
 assertThat(metric.getDecimalScale()).isEqualTo(3);
}

代码示例来源:origin: SonarSource/sonarqube

@Test
 public void non_decimal_metric_has_no_scale() {
  Metric metric = new Metric.Builder("foo", "Foo", Metric.ValueType.INT)
   .create();
  assertThat(metric.getDecimalScale()).isNull();
 }
}

代码示例来源:origin: SonarSource/sonarqube

private static Metric from(int id, org.sonar.api.measures.Metric<?> coreMetric) {
 return new MetricImpl(
  id, coreMetric.getKey(), coreMetric.getName(),
  convert(coreMetric.getType()),
  coreMetric.getDecimalScale(),
  coreMetric.getBestValue(), coreMetric.isOptimizedBestValue());
}

代码示例来源:origin: SonarSource/sonarqube

@Override
 @Nonnull
 public MetricDto apply(@Nonnull Metric metric) {
  MetricDto dto = new MetricDto();
  dto.setId(metric.getId());
  dto.setKey(metric.getKey());
  dto.setDescription(metric.getDescription());
  dto.setShortName(metric.getName());
  dto.setBestValue(metric.getBestValue());
  dto.setDomain(metric.getDomain());
  dto.setEnabled(metric.getEnabled());
  dto.setDirection(metric.getDirection());
  dto.setHidden(metric.isHidden());
  dto.setQualitative(metric.getQualitative());
  dto.setValueType(metric.getType().name());
  dto.setOptimizedBestValue(metric.isOptimizedBestValue());
  dto.setUserManaged(metric.getUserManaged());
  dto.setWorstValue(metric.getWorstValue());
  dto.setDeleteHistoricalData(metric.getDeleteHistoricalData());
  dto.setDecimalScale(metric.getDecimalScale());
  return dto;
 }
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-server

@Override
 @Nonnull
 public MetricDto apply(@Nonnull Metric metric) {
  MetricDto dto = new MetricDto();
  dto.setId(metric.getId());
  dto.setKey(metric.getKey());
  dto.setDescription(metric.getDescription());
  dto.setShortName(metric.getName());
  dto.setBestValue(metric.getBestValue());
  dto.setDomain(metric.getDomain());
  dto.setEnabled(metric.getEnabled());
  dto.setDirection(metric.getDirection());
  dto.setHidden(metric.isHidden());
  dto.setQualitative(metric.getQualitative());
  dto.setValueType(metric.getType().name());
  dto.setOptimizedBestValue(metric.isOptimizedBestValue());
  dto.setUserManaged(metric.getUserManaged());
  dto.setWorstValue(metric.getWorstValue());
  dto.setDeleteHistoricalData(metric.getDeleteHistoricalData());
  dto.setDecimalScale(metric.getDecimalScale());
  return dto;
 }
}

相关文章