RolledUpStatisticEvent implements Iterable<TimeAgnosticStatisticEvent> { @Override public Iterator<TimeAgnosticStatisticEvent> iterator() { return new Iterator<TimeAgnosticStatisticEvent>() { int nextElement = 0; @Override public boolean hasNext() { if (tagListPermutations == null || tagListPermutations.size() == 0) { return false; } return nextElement < tagListPermutations.size(); } @Override public TimeAgnosticStatisticEvent next() { if (tagListPermutations == null || tagListPermutations.size() == 0) { return null; } if (originalStatisticEvent.getType().equals(StatisticType.COUNT)) { return TimeAgnosticStatisticEvent.createCount(originalStatisticEvent.getName(), tagListPermutations.get(nextElement++), originalStatisticEvent.getCount()); } else { return TimeAgnosticStatisticEvent.createValue(originalStatisticEvent.getName(), tagListPermutations.get(nextElement++), originalStatisticEvent.getValue()); } } @Override public void remove() { throw new UnsupportedOperationException("Remove is not supported for this class"); } }; } RolledUpStatisticEvent(final StatisticEvent originalStatisticEvent,
                                  final List<List<StatisticTag>> tagListPermutations);  RolledUpStatisticEvent(final StatisticEvent originalStatisticEvent); long getTimeMs(); StatisticType getType(); String getName(); double getValue(); long getCount(); int getPermutationCount(); @Override Iterator<TimeAgnosticStatisticEvent> iterator(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }
@Test void testRolledUpStatisticEventStatisticEvent() { buildEvent(); final RolledUpStatisticEvent rolledUpStatisticEvent = new RolledUpStatisticEvent(event); compareEvents(event, rolledUpStatisticEvent); assertThat(rolledUpStatisticEvent.iterator().hasNext()).isTrue(); int counter = 0; for (final TimeAgnosticStatisticEvent timeAgnosticStatisticEvent : rolledUpStatisticEvent) { assertThat(timeAgnosticStatisticEvent).isEqualTo(event.getTimeAgnosticStatisticEvent()); counter++; } assertThat(counter).isEqualTo(1); }