public List<MetricData> getData(int span) {
        int count = span / period;
        if (dataList.size() < count) {
            if (dataList.isEmpty()) {
                return dataList;
            }
            else {
                // left-pad
                List<MetricData> padded = new ArrayList<>(dataList);
                MetricData first = dataList.get(0);
                List<Metric> pads = new ArrayList<>();
                for (Metric metric : first.getMetrics()) {
                    pads.add(new Metric(metric.getId(), metric.getName(), 0));
                }
                LocalDateTime time = first.getTime();
                while (padded.size() < count) {
                    time = time.minusSeconds(period);
                    padded.add(0, new MetricData(time, pads));
                }
                return padded;
            }
        }
        else {
            return dataList.subList(dataList.size() - count, dataList.size() - 1);
        }
    }
public List < MetricData > getData ( int span ) { int count = span / period ; if ( dataList . size ( ) < count ) { if ( dataList . isEmpty ( ) ) { return dataList ; } else { List < MetricData > padded = new ArrayList < > ( dataList ) ; MetricData first = dataList . get ( 0 ) ; List < Metric > pads = new ArrayList < > ( ) ; for ( Metric metric : first . getMetrics ( ) ) { pads . add ( new Metric ( metric . getId ( ) , metric . getName ( ) , 0 ) ) ; } LocalDateTime time = first . getTime ( ) ; while ( padded . size ( ) < count ) { time = time . minusSeconds ( period ) ; padded . add ( 0 , new MetricData ( time , pads ) ) ; } return padded ; } } else { return dataList . subList ( dataList . size ( ) - count , dataList . size ( ) - 1 ) ; } }
Returns a left-padded list.