<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: google/datastore/v1/query.proto

namespace Google\Cloud\Datastore\V1;

use Google\Protobuf\Internal\GPBType;
use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;

/**
 * The result of fetching an entity from Datastore.
 *
 * Generated from protobuf message <code>google.datastore.v1.EntityResult</code>
 */
class EntityResult extends \Google\Protobuf\Internal\Message
{
    /**
     * The resulting entity.
     *
     * Generated from protobuf field <code>.google.datastore.v1.Entity entity = 1;</code>
     */
    private $entity = null;
    /**
     * The version of the entity, a strictly positive number that monotonically
     * increases with changes to the entity.
     * This field is set for
     * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
     * For [missing][google.datastore.v1.LookupResponse.missing] entities in
     * `LookupResponse`, this is the version of the snapshot that was used to look
     * up the entity, and it is always set except for eventually consistent reads.
     *
     * Generated from protobuf field <code>int64 version = 4;</code>
     */
    private $version = 0;
    /**
     * The time at which the entity was created.
     * This field is set for
     * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
     * If this entity is missing, this field will not be set.
     *
     * Generated from protobuf field <code>.google.protobuf.Timestamp create_time = 6;</code>
     */
    private $create_time = null;
    /**
     * The time at which the entity was last changed.
     * This field is set for
     * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
     * If this entity is missing, this field will not be set.
     *
     * Generated from protobuf field <code>.google.protobuf.Timestamp update_time = 5;</code>
     */
    private $update_time = null;
    /**
     * A cursor that points to the position after the result entity.
     * Set only when the `EntityResult` is part of a `QueryResultBatch` message.
     *
     * Generated from protobuf field <code>bytes cursor = 3;</code>
     */
    private $cursor = '';

    /**
     * Constructor.
     *
     * @param array $data {
     *     Optional. Data for populating the Message object.
     *
     *     @type \Google\Cloud\Datastore\V1\Entity $entity
     *           The resulting entity.
     *     @type int|string $version
     *           The version of the entity, a strictly positive number that monotonically
     *           increases with changes to the entity.
     *           This field is set for
     *           [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
     *           For [missing][google.datastore.v1.LookupResponse.missing] entities in
     *           `LookupResponse`, this is the version of the snapshot that was used to look
     *           up the entity, and it is always set except for eventually consistent reads.
     *     @type \Google\Protobuf\Timestamp $create_time
     *           The time at which the entity was created.
     *           This field is set for
     *           [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
     *           If this entity is missing, this field will not be set.
     *     @type \Google\Protobuf\Timestamp $update_time
     *           The time at which the entity was last changed.
     *           This field is set for
     *           [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
     *           If this entity is missing, this field will not be set.
     *     @type string $cursor
     *           A cursor that points to the position after the result entity.
     *           Set only when the `EntityResult` is part of a `QueryResultBatch` message.
     * }
     */
    public function __construct($data = NULL) {
        \GPBMetadata\Google\Datastore\V1\Query::initOnce();
        parent::__construct($data);
    }

    /**
     * The resulting entity.
     *
     * Generated from protobuf field <code>.google.datastore.v1.Entity entity = 1;</code>
     * @return \Google\Cloud\Datastore\V1\Entity|null
     */
    public function getEntity()
    {
        return $this->entity;
    }

    public function hasEntity()
    {
        return isset($this->entity);
    }

    public function clearEntity()
    {
        unset($this->entity);
    }

    /**
     * The resulting entity.
     *
     * Generated from protobuf field <code>.google.datastore.v1.Entity entity = 1;</code>
     * @param \Google\Cloud\Datastore\V1\Entity $var
     * @return $this
     */
    public function setEntity($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\Datastore\V1\Entity::class);
        $this->entity = $var;

        return $this;
    }

    /**
     * The version of the entity, a strictly positive number that monotonically
     * increases with changes to the entity.
     * This field is set for
     * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
     * For [missing][google.datastore.v1.LookupResponse.missing] entities in
     * `LookupResponse`, this is the version of the snapshot that was used to look
     * up the entity, and it is always set except for eventually consistent reads.
     *
     * Generated from protobuf field <code>int64 version = 4;</code>
     * @return int|string
     */
    public function getVersion()
    {
        return $this->version;
    }

    /**
     * The version of the entity, a strictly positive number that monotonically
     * increases with changes to the entity.
     * This field is set for
     * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
     * For [missing][google.datastore.v1.LookupResponse.missing] entities in
     * `LookupResponse`, this is the version of the snapshot that was used to look
     * up the entity, and it is always set except for eventually consistent reads.
     *
     * Generated from protobuf field <code>int64 version = 4;</code>
     * @param int|string $var
     * @return $this
     */
    public function setVersion($var)
    {
        GPBUtil::checkInt64($var);
        $this->version = $var;

        return $this;
    }

    /**
     * The time at which the entity was created.
     * This field is set for
     * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
     * If this entity is missing, this field will not be set.
     *
     * Generated from protobuf field <code>.google.protobuf.Timestamp create_time = 6;</code>
     * @return \Google\Protobuf\Timestamp|null
     */
    public function getCreateTime()
    {
        return $this->create_time;
    }

    public function hasCreateTime()
    {
        return isset($this->create_time);
    }

    public function clearCreateTime()
    {
        unset($this->create_time);
    }

    /**
     * The time at which the entity was created.
     * This field is set for
     * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
     * If this entity is missing, this field will not be set.
     *
     * Generated from protobuf field <code>.google.protobuf.Timestamp create_time = 6;</code>
     * @param \Google\Protobuf\Timestamp $var
     * @return $this
     */
    public function setCreateTime($var)
    {
        GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class);
        $this->create_time = $var;

        return $this;
    }

    /**
     * The time at which the entity was last changed.
     * This field is set for
     * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
     * If this entity is missing, this field will not be set.
     *
     * Generated from protobuf field <code>.google.protobuf.Timestamp update_time = 5;</code>
     * @return \Google\Protobuf\Timestamp|null
     */
    public function getUpdateTime()
    {
        return $this->update_time;
    }

    public function hasUpdateTime()
    {
        return isset($this->update_time);
    }

    public function clearUpdateTime()
    {
        unset($this->update_time);
    }

    /**
     * The time at which the entity was last changed.
     * This field is set for
     * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
     * If this entity is missing, this field will not be set.
     *
     * Generated from protobuf field <code>.google.protobuf.Timestamp update_time = 5;</code>
     * @param \Google\Protobuf\Timestamp $var
     * @return $this
     */
    public function setUpdateTime($var)
    {
        GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class);
        $this->update_time = $var;

        return $this;
    }

    /**
     * A cursor that points to the position after the result entity.
     * Set only when the `EntityResult` is part of a `QueryResultBatch` message.
     *
     * Generated from protobuf field <code>bytes cursor = 3;</code>
     * @return string
     */
    public function getCursor()
    {
        return $this->cursor;
    }

    /**
     * A cursor that points to the position after the result entity.
     * Set only when the `EntityResult` is part of a `QueryResultBatch` message.
     *
     * Generated from protobuf field <code>bytes cursor = 3;</code>
     * @param string $var
     * @return $this
     */
    public function setCursor($var)
    {
        GPBUtil::checkString($var, False);
        $this->cursor = $var;

        return $this;
    }

}

