public function load(AggregateId $aggregateId) : AggregateRoot
    {
        $aggregateRootClass = ObjectClass::forName($aggregateId->aggregateClass());
        $aggregate = null;
        $stateHash = null;
        if ($this->eventStore instanceof SnapshotEventStore) {
            $aggregate = $this->eventStore->loadSnapshot($aggregateId);
            $stateHash = $aggregate === null
                ? null
                : $aggregate->stateHash();
        }
        $events = $this->eventStore->getEventsFor($aggregateId, $stateHash);
        if ($aggregate === null) {
            Preconditions::checkArgument($events->valid(), 'Aggregate with ID [%s] does not exist', $aggregateId);
            $aggregate = $aggregateRootClass->newInstanceWithoutConstructor();
        }
        $aggregateRootClass->cast($aggregate);
        $aggregate->loadFromHistory($events);
        return $aggregate;
    }