static Command createMetricCommand (ResourceKey resKey, TimeRange range, String key, PointType pt, Collection<? extends IDataPoint> points) { if (ListUtil.size(points) <= 0) { return null; } ResourceMetricKey metricKey = ResourceMetricKey.valueOf(resKey, MetricKey.valueOf(key)); switch (pt) { case COUNTER: { CounterMetricValueBuilder valueBuilder = new CounterMetricValueBuilder(range); CounterMetricValue mValue = (CounterMetricValue)aggregateValue(points, valueBuilder); return new UpdateMetricCommand(metricKey, mValue); } case GAUGE: { GaugeMetricValueBuilder valueBuilder=new GaugeMetricValueBuilder(range); GaugeMetricValue gValue = (GaugeMetricValue)aggregateValue(points, valueBuilder); return new UpdateMetricDistributionCommand(metricKey, gValue); } default: throw new IllegalStateException("createMetricCommand(" + metricKey + ")[" + range + "] unhandled point type: " + pt); } }