Make MetricsProperties fields final if possible

Closes gh-13324
pull/13322/merge
Johnny Lim 7 years ago committed by Stephane Nicoll
parent 77dcbdb1e5
commit 5d5a14e4f7

@ -20,7 +20,6 @@ import java.util.LinkedHashMap;
import java.util.Map;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.util.Assert;
/**
* {@link ConfigurationProperties} for configuring Micrometer-based metrics.
@ -42,7 +41,7 @@ public class MetricsProperties {
* Whether meter IDs starting-with the specified name should be enabled. The longest
* match wins, the key `all` can also be used to configure all meters.
*/
private Map<String, Boolean> enable = new LinkedHashMap<>();
private final Map<String, Boolean> enable = new LinkedHashMap<>();
/**
* Common tags that are applied to every meter.
@ -65,11 +64,6 @@ public class MetricsProperties {
return this.enable;
}
public void setEnable(Map<String, Boolean> enable) {
Assert.notNull(enable, "enable must not be null");
this.enable = enable;
}
public Map<String, String> getTags() {
return this.tags;
}
@ -172,14 +166,14 @@ public class MetricsProperties {
* this has no effect. The longest match wins, the key `all` can also be used to
* configure all meters.
*/
private Map<String, Boolean> percentilesHistogram = new LinkedHashMap<>();
private final Map<String, Boolean> percentilesHistogram = new LinkedHashMap<>();
/**
* Specific computed non-aggregable percentiles to ship to the backend for meter
* IDs starting-with the specified name. The longest match wins, the key `all` can
* also be used to configure all meters.
*/
private Map<String, double[]> percentiles = new LinkedHashMap<>();
private final Map<String, double[]> percentiles = new LinkedHashMap<>();
/**
* Specific SLA boundaries for meter IDs starting-with the specified name. The
@ -188,35 +182,20 @@ public class MetricsProperties {
* as a long or as a Duration value (for timer meters, defaulting to ms if no unit
* specified).
*/
private Map<String, ServiceLevelAgreementBoundary[]> sla = new LinkedHashMap<>();
private final Map<String, ServiceLevelAgreementBoundary[]> sla = new LinkedHashMap<>();
public Map<String, Boolean> getPercentilesHistogram() {
return this.percentilesHistogram;
}
public void setPercentilesHistogram(Map<String, Boolean> percentilesHistogram) {
Assert.notNull(percentilesHistogram, "PercentilesHistogram must not be null");
this.percentilesHistogram = percentilesHistogram;
}
public Map<String, double[]> getPercentiles() {
return this.percentiles;
}
public void setPercentiles(Map<String, double[]> percentiles) {
Assert.notNull(percentiles, "Percentiles must not be null");
this.percentiles = percentiles;
}
public Map<String, ServiceLevelAgreementBoundary[]> getSla() {
return this.sla;
}
public void setSla(Map<String, ServiceLevelAgreementBoundary[]> sla) {
Assert.notNull(sla, "SLA must not be null");
this.sla = sla;
}
}
}

Loading…
Cancel
Save