<?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;

/**
 * A holder for any type of filter.
 *
 * Generated from protobuf message <code>google.datastore.v1.Filter</code>
 */
class Filter extends \Google\Protobuf\Internal\Message
{
    protected $filter_type;

    /**
     * Constructor.
     *
     * @param array $data {
     *     Optional. Data for populating the Message object.
     *
     *     @type \Google\Cloud\Datastore\V1\CompositeFilter $composite_filter
     *           A composite filter.
     *     @type \Google\Cloud\Datastore\V1\PropertyFilter $property_filter
     *           A filter on a property.
     * }
     */
    public function __construct($data = NULL) {
        \GPBMetadata\Google\Datastore\V1\Query::initOnce();
        parent::__construct($data);
    }

    /**
     * A composite filter.
     *
     * Generated from protobuf field <code>.google.datastore.v1.CompositeFilter composite_filter = 1;</code>
     * @return \Google\Cloud\Datastore\V1\CompositeFilter
     */
    public function getCompositeFilter()
    {
        return $this->readOneof(1);
    }

    public function hasCompositeFilter()
    {
        return $this->hasOneof(1);
    }

    /**
     * A composite filter.
     *
     * Generated from protobuf field <code>.google.datastore.v1.CompositeFilter composite_filter = 1;</code>
     * @param \Google\Cloud\Datastore\V1\CompositeFilter $var
     * @return $this
     */
    public function setCompositeFilter($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\Datastore\V1\CompositeFilter::class);
        $this->writeOneof(1, $var);

        return $this;
    }

    /**
     * A filter on a property.
     *
     * Generated from protobuf field <code>.google.datastore.v1.PropertyFilter property_filter = 2;</code>
     * @return \Google\Cloud\Datastore\V1\PropertyFilter
     */
    public function getPropertyFilter()
    {
        return $this->readOneof(2);
    }

    public function hasPropertyFilter()
    {
        return $this->hasOneof(2);
    }

    /**
     * A filter on a property.
     *
     * Generated from protobuf field <code>.google.datastore.v1.PropertyFilter property_filter = 2;</code>
     * @param \Google\Cloud\Datastore\V1\PropertyFilter $var
     * @return $this
     */
    public function setPropertyFilter($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\Datastore\V1\PropertyFilter::class);
        $this->writeOneof(2, $var);

        return $this;
    }

    /**
     * @return string
     */
    public function getFilterType()
    {
        return $this->whichOneof("filter_type");
    }

}

