@Test public void unionOfEmptyMetricSetsIsEmpty() { assertThat(disjointUnionTaggedMetricSet.getMetrics()).isEmpty(); }
@Override public Map<MetricName, Metric> getMetrics() { Map<MetricName, Metric> firstMetrics = first.getMetrics(); Map<MetricName, Metric> secondMetrics = second.getMetrics(); Map<MetricName, Metric> metrics = new HashMap<>(firstMetrics.size() + secondMetrics.size()); firstMetrics.forEach(metrics::putIfAbsent); secondMetrics.forEach((metricName, metric) -> { if (metrics.putIfAbsent(metricName, metric) != null) { log.warn("Detected duplicate metric name", SafeArg.of("metricName", metricName)); } }); return Collections.unmodifiableMap(metrics); }
DisjointUnionTaggedMetricSet implements TaggedMetricSet { @Override public Map<MetricName, Metric> getMetrics() { Map<MetricName, Metric> firstMetrics = first.getMetrics(); Map<MetricName, Metric> secondMetrics = second.getMetrics(); Map<MetricName, Metric> metrics = new HashMap<>(firstMetrics.size() + secondMetrics.size()); firstMetrics.forEach(metrics::putIfAbsent); secondMetrics.forEach((metricName, metric) -> { if (metrics.putIfAbsent(metricName, metric) != null) { log.warn("Detected duplicate metric name", SafeArg.of("metricName", metricName)); } }); return Collections.unmodifiableMap(metrics); } }
DisjointUnionTaggedMetricSet implements TaggedMetricSet { @Override public Map<MetricName, Metric> getMetrics() { Map<MetricName, Metric> firstMetrics = first.getMetrics(); Map<MetricName, Metric> secondMetrics = second.getMetrics(); Map<MetricName, Metric> metrics = new HashMap<>(firstMetrics.size() + secondMetrics.size()); firstMetrics.forEach(metrics::putIfAbsent); secondMetrics.forEach((metricName, metric) -> { if (metrics.putIfAbsent(metricName, metric) != null) { log.warn("Detected duplicate metric name", SafeArg.of("metricName", metricName)); } }); return Collections.unmodifiableMap(metrics); } DisjointUnionTaggedMetricSet(TaggedMetricSet first, TaggedMetricSet second); }
DisjointUnionTaggedMetricSet implements TaggedMetricSet { @Override public Map<MetricName, Metric> getMetrics() { Map<MetricName, Metric> firstMetrics = first.getMetrics(); Map<MetricName, Metric> secondMetrics = second.getMetrics(); Map<MetricName, Metric> metrics = new HashMap<>(firstMetrics.size() + secondMetrics.size()); firstMetrics.forEach(metrics::putIfAbsent); secondMetrics.forEach((metricName, metric) -> { if (metrics.putIfAbsent(metricName, metric) != null) { log.warn("Detected duplicate metric name", SafeArg.of("metricName", metricName)); } }); return Collections.unmodifiableMap(metrics); } DisjointUnionTaggedMetricSet(TaggedMetricSet first, TaggedMetricSet second); @Override Map<MetricName, Metric> getMetrics(); @Override void forEachMetric(BiConsumer<MetricName, Metric> consumer); }
DisjointUnionTaggedMetricSet implements TaggedMetricSet { @Override public Map<MetricName, Metric> getMetrics() { Map<MetricName, Metric> firstMetrics = first.getMetrics(); Map<MetricName, Metric> secondMetrics = second.getMetrics(); Map<MetricName, Metric> metrics = new HashMap<>(firstMetrics.size() + secondMetrics.size()); firstMetrics.forEach(metrics::putIfAbsent); secondMetrics.forEach((metricName, metric) -> { if (metrics.putIfAbsent(metricName, metric) != null) { log.warn("Detected duplicate metric name", SafeArg.of("metricName", metricName)); } }); return Collections.unmodifiableMap(metrics); } DisjointUnionTaggedMetricSet(TaggedMetricSet first, TaggedMetricSet second); @Override Map<MetricName, Metric> getMetrics(); @Override void forEachMetric(BiConsumer<MetricName, Metric> consumer);  }