List < Object > alignResults ( List < QueryResult > results , String epoch ) { Object [ ] alignedResults = new Object [ results . size ( ) + 1 ] ; List < String > headerList = Arrays . asList ( header ) ; alignedResults [ 0 ] = epoch ; for ( QueryResult result : results ) { alignedResults [ headerList . indexOf ( result . getName ( ) ) ] = result . getValue ( ) ; } return Arrays . asList ( alignedResults ) ; }
We have no guarantee that the results will always be in the same order so we make sure to align them according to the header on each query .