}
}
public void restoreState(EventStream eventStream) {
Iterator<Event> iterator = eventStream.iterator();
CreatedMatchEvent createdMatchEvent = (CreatedMatchEvent) iterator.next();
if (createdMatchEvent == null)
throw new RuntimeException("Restoring state failed");
this.match = new Match(UUID.randomUUID(), createdMatchEvent.getPlayersMap());
// Execute all arisen events.
while (iterator.hasNext()) {
Event next = iterator.next();
next.execute(this.match);