Advertisement
Guest User

Untitled

a guest
Sep 27th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. global class AggregateResultIterator implements Iterator<AggregateResult> {
  2. AggregateResult [] results {get;set;}
  3. // tracks which result item is returned
  4. Integer index {get; set;}
  5.  
  6. global AggregateResultIterator(String query) {
  7. index = 0;
  8. results = Database.query(query);
  9. }
  10.  
  11. global boolean hasNext(){
  12. return results != null && !results.isEmpty() && index < results.size();
  13. }
  14.  
  15. global AggregateResult next(){
  16. return results[index++];
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement