private function setEntityFactory(IEntityFactory $entityFactory)
{
if ($this->entityFactory === null) {
$this->entityFactory = $entityFactory;
} elseif ($this->entityFactory != $entityFactory) {
// intentionally !=, we want to ensure that types and states are same
throw new InvalidStateException("Given entity factory isn't same as entity factory already present in entity " . get_called_class() . '.');
}
}