/**
  * @return \Google_Service_Datastore_Entity
  * @throws DatastoreHelperException
  */
 public function exportEntity()
 {
     if (empty($this->definedProperties)) {
         throw new DatastoreHelperException('No properties were defined in ' . self::class);
     }
     $entity = new \Google_Service_Datastore_Entity();
     if ($this->getKey() === null) {
         $entity->setKey($this->getKey());
     } else {
         $entity->setKey($this->getKey());
     }
     $properties = [];
     foreach ($this->definedProperties as $name => $spec) {
         $properties[$name] = \DatastoreHelper::newProperty($this->{$name}, $spec['type'], $spec['indexed']);
     }
     $entity->setProperties($properties);
     return $entity;
 }