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

namespace Google\Ads\AdManager\V1\ReportDefinition;

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

/**
 * Represents a sorting in a report.
 *
 * Generated from protobuf message <code>google.ads.admanager.v1.ReportDefinition.Sort</code>
 */
class Sort extends \Google\Protobuf\Internal\Message
{
    /**
     * Required. A field (dimension or metric) to sort by.
     *
     * Generated from protobuf field <code>.google.ads.admanager.v1.ReportDefinition.Field field = 1 [(.google.api.field_behavior) = REQUIRED];</code>
     */
    protected $field = null;
    /**
     * Optional. The sort order. If true the sort will be descending.
     *
     * Generated from protobuf field <code>bool descending = 2 [(.google.api.field_behavior) = OPTIONAL];</code>
     */
    protected $descending = false;
    /**
     * Optional. Use to sort on a specific slice of data.
     *
     * Generated from protobuf field <code>optional .google.ads.admanager.v1.ReportDefinition.Slice slice = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
     */
    protected $slice = null;
    /**
     * Optional. When using time period columns, use this to sort on a specific
     * column.
     *
     * Generated from protobuf field <code>optional int32 time_period_index = 4 [(.google.api.field_behavior) = OPTIONAL];</code>
     */
    protected $time_period_index = null;
    /**
     * Optional. Use to specify which metric value type to sort on. Defaults to
     * PRIMARY.
     *
     * Generated from protobuf field <code>optional .google.ads.admanager.v1.ReportDefinition.MetricValueType metric_value_type = 5 [(.google.api.field_behavior) = OPTIONAL];</code>
     */
    protected $metric_value_type = null;

    /**
     * Constructor.
     *
     * @param array $data {
     *     Optional. Data for populating the Message object.
     *
     *     @type \Google\Ads\AdManager\V1\ReportDefinition\Field $field
     *           Required. A field (dimension or metric) to sort by.
     *     @type bool $descending
     *           Optional. The sort order. If true the sort will be descending.
     *     @type \Google\Ads\AdManager\V1\ReportDefinition\Slice $slice
     *           Optional. Use to sort on a specific slice of data.
     *     @type int $time_period_index
     *           Optional. When using time period columns, use this to sort on a specific
     *           column.
     *     @type int $metric_value_type
     *           Optional. Use to specify which metric value type to sort on. Defaults to
     *           PRIMARY.
     * }
     */
    public function __construct($data = NULL) {
        \GPBMetadata\Google\Ads\Admanager\V1\ReportDefinition::initOnce();
        parent::__construct($data);
    }

    /**
     * Required. A field (dimension or metric) to sort by.
     *
     * Generated from protobuf field <code>.google.ads.admanager.v1.ReportDefinition.Field field = 1 [(.google.api.field_behavior) = REQUIRED];</code>
     * @return \Google\Ads\AdManager\V1\ReportDefinition\Field|null
     */
    public function getField()
    {
        return $this->field;
    }

    public function hasField()
    {
        return isset($this->field);
    }

    public function clearField()
    {
        unset($this->field);
    }

    /**
     * Required. A field (dimension or metric) to sort by.
     *
     * Generated from protobuf field <code>.google.ads.admanager.v1.ReportDefinition.Field field = 1 [(.google.api.field_behavior) = REQUIRED];</code>
     * @param \Google\Ads\AdManager\V1\ReportDefinition\Field $var
     * @return $this
     */
    public function setField($var)
    {
        GPBUtil::checkMessage($var, \Google\Ads\AdManager\V1\ReportDefinition\Field::class);
        $this->field = $var;

        return $this;
    }

    /**
     * Optional. The sort order. If true the sort will be descending.
     *
     * Generated from protobuf field <code>bool descending = 2 [(.google.api.field_behavior) = OPTIONAL];</code>
     * @return bool
     */
    public function getDescending()
    {
        return $this->descending;
    }

    /**
     * Optional. The sort order. If true the sort will be descending.
     *
     * Generated from protobuf field <code>bool descending = 2 [(.google.api.field_behavior) = OPTIONAL];</code>
     * @param bool $var
     * @return $this
     */
    public function setDescending($var)
    {
        GPBUtil::checkBool($var);
        $this->descending = $var;

        return $this;
    }

    /**
     * Optional. Use to sort on a specific slice of data.
     *
     * Generated from protobuf field <code>optional .google.ads.admanager.v1.ReportDefinition.Slice slice = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
     * @return \Google\Ads\AdManager\V1\ReportDefinition\Slice|null
     */
    public function getSlice()
    {
        return $this->slice;
    }

    public function hasSlice()
    {
        return isset($this->slice);
    }

    public function clearSlice()
    {
        unset($this->slice);
    }

    /**
     * Optional. Use to sort on a specific slice of data.
     *
     * Generated from protobuf field <code>optional .google.ads.admanager.v1.ReportDefinition.Slice slice = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
     * @param \Google\Ads\AdManager\V1\ReportDefinition\Slice $var
     * @return $this
     */
    public function setSlice($var)
    {
        GPBUtil::checkMessage($var, \Google\Ads\AdManager\V1\ReportDefinition\Slice::class);
        $this->slice = $var;

        return $this;
    }

    /**
     * Optional. When using time period columns, use this to sort on a specific
     * column.
     *
     * Generated from protobuf field <code>optional int32 time_period_index = 4 [(.google.api.field_behavior) = OPTIONAL];</code>
     * @return int
     */
    public function getTimePeriodIndex()
    {
        return isset($this->time_period_index) ? $this->time_period_index : 0;
    }

    public function hasTimePeriodIndex()
    {
        return isset($this->time_period_index);
    }

    public function clearTimePeriodIndex()
    {
        unset($this->time_period_index);
    }

    /**
     * Optional. When using time period columns, use this to sort on a specific
     * column.
     *
     * Generated from protobuf field <code>optional int32 time_period_index = 4 [(.google.api.field_behavior) = OPTIONAL];</code>
     * @param int $var
     * @return $this
     */
    public function setTimePeriodIndex($var)
    {
        GPBUtil::checkInt32($var);
        $this->time_period_index = $var;

        return $this;
    }

    /**
     * Optional. Use to specify which metric value type to sort on. Defaults to
     * PRIMARY.
     *
     * Generated from protobuf field <code>optional .google.ads.admanager.v1.ReportDefinition.MetricValueType metric_value_type = 5 [(.google.api.field_behavior) = OPTIONAL];</code>
     * @return int
     */
    public function getMetricValueType()
    {
        return isset($this->metric_value_type) ? $this->metric_value_type : 0;
    }

    public function hasMetricValueType()
    {
        return isset($this->metric_value_type);
    }

    public function clearMetricValueType()
    {
        unset($this->metric_value_type);
    }

    /**
     * Optional. Use to specify which metric value type to sort on. Defaults to
     * PRIMARY.
     *
     * Generated from protobuf field <code>optional .google.ads.admanager.v1.ReportDefinition.MetricValueType metric_value_type = 5 [(.google.api.field_behavior) = OPTIONAL];</code>
     * @param int $var
     * @return $this
     */
    public function setMetricValueType($var)
    {
        GPBUtil::checkEnum($var, \Google\Ads\AdManager\V1\ReportDefinition\MetricValueType::class);
        $this->metric_value_type = $var;

        return $this;
    }

}


