boolean hasAllZeroData(MetricData dataPoints) { boolean allZeroFlag = true; // Points should be of type BasicRollup. Will throw an exception if they are not. Map<Long, Points.Point<BasicRollup>> points = dataPoints.getData().getPoints(); for (Map.Entry<Long, Points.Point<BasicRollup>> entry : points.entrySet()) { BasicRollup basicRollup = entry.getValue().getData(); if ((basicRollup.getMaxValue().isFloatingPoint() ? basicRollup.getMaxValue().toDouble() != 0.0 : basicRollup.getMaxValue().toLong() != 0) && (basicRollup.getMinValue().isFloatingPoint() ? basicRollup.getMinValue().toDouble() != 0.0 : basicRollup.getMinValue().toLong() != 0) && (basicRollup.getAverage().isFloatingPoint() ? basicRollup.getAverage().toDouble() != 0.0 : basicRollup.getAverage().toLong() != 0)) { allZeroFlag = false; break; } } return allZeroFlag; }
public static Points<BasicRollup> generateFakeRollupPoints() { Points<BasicRollup> points = new Points<BasicRollup>(); long baseTime = 1234567L; for (int count = 0; count < 5; count++) { final BasicRollup basicRollup = new BasicRollup(); basicRollup.setCount(count * 100); basicRollup.getAverage().setLongValue(count); Points.Point<BasicRollup> point = new Points.Point<BasicRollup>(baseTime + (count * 1000), basicRollup); points.add(point); } return points; }