<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: google/cloud/dialogflow/v2/participant.proto

namespace Google\Cloud\Dialogflow\V2\KnowledgeAssistAnswer;

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

/**
 * Represents an answer from Knowledge. Currently supports FAQ and Generative
 * answers.
 *
 * Generated from protobuf message <code>google.cloud.dialogflow.v2.KnowledgeAssistAnswer.KnowledgeAnswer</code>
 */
class KnowledgeAnswer extends \Google\Protobuf\Internal\Message
{
    /**
     * The piece of text from the `source` that answers this suggested query.
     *
     * Generated from protobuf field <code>string answer_text = 1;</code>
     */
    protected $answer_text = '';
    protected $source;

    /**
     * Constructor.
     *
     * @param array $data {
     *     Optional. Data for populating the Message object.
     *
     *     @type string $answer_text
     *           The piece of text from the `source` that answers this suggested query.
     *     @type \Google\Cloud\Dialogflow\V2\KnowledgeAssistAnswer\KnowledgeAnswer\FaqSource $faq_source
     *           Populated if the prediction came from FAQ.
     *     @type \Google\Cloud\Dialogflow\V2\KnowledgeAssistAnswer\KnowledgeAnswer\GenerativeSource $generative_source
     *           Populated if the prediction was Generative.
     * }
     */
    public function __construct($data = NULL) {
        \GPBMetadata\Google\Cloud\Dialogflow\V2\Participant::initOnce();
        parent::__construct($data);
    }

    /**
     * The piece of text from the `source` that answers this suggested query.
     *
     * Generated from protobuf field <code>string answer_text = 1;</code>
     * @return string
     */
    public function getAnswerText()
    {
        return $this->answer_text;
    }

    /**
     * The piece of text from the `source` that answers this suggested query.
     *
     * Generated from protobuf field <code>string answer_text = 1;</code>
     * @param string $var
     * @return $this
     */
    public function setAnswerText($var)
    {
        GPBUtil::checkString($var, True);
        $this->answer_text = $var;

        return $this;
    }

    /**
     * Populated if the prediction came from FAQ.
     *
     * Generated from protobuf field <code>.google.cloud.dialogflow.v2.KnowledgeAssistAnswer.KnowledgeAnswer.FaqSource faq_source = 3;</code>
     * @return \Google\Cloud\Dialogflow\V2\KnowledgeAssistAnswer\KnowledgeAnswer\FaqSource|null
     */
    public function getFaqSource()
    {
        return $this->readOneof(3);
    }

    public function hasFaqSource()
    {
        return $this->hasOneof(3);
    }

    /**
     * Populated if the prediction came from FAQ.
     *
     * Generated from protobuf field <code>.google.cloud.dialogflow.v2.KnowledgeAssistAnswer.KnowledgeAnswer.FaqSource faq_source = 3;</code>
     * @param \Google\Cloud\Dialogflow\V2\KnowledgeAssistAnswer\KnowledgeAnswer\FaqSource $var
     * @return $this
     */
    public function setFaqSource($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\Dialogflow\V2\KnowledgeAssistAnswer\KnowledgeAnswer\FaqSource::class);
        $this->writeOneof(3, $var);

        return $this;
    }

    /**
     * Populated if the prediction was Generative.
     *
     * Generated from protobuf field <code>.google.cloud.dialogflow.v2.KnowledgeAssistAnswer.KnowledgeAnswer.GenerativeSource generative_source = 4;</code>
     * @return \Google\Cloud\Dialogflow\V2\KnowledgeAssistAnswer\KnowledgeAnswer\GenerativeSource|null
     */
    public function getGenerativeSource()
    {
        return $this->readOneof(4);
    }

    public function hasGenerativeSource()
    {
        return $this->hasOneof(4);
    }

    /**
     * Populated if the prediction was Generative.
     *
     * Generated from protobuf field <code>.google.cloud.dialogflow.v2.KnowledgeAssistAnswer.KnowledgeAnswer.GenerativeSource generative_source = 4;</code>
     * @param \Google\Cloud\Dialogflow\V2\KnowledgeAssistAnswer\KnowledgeAnswer\GenerativeSource $var
     * @return $this
     */
    public function setGenerativeSource($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\Dialogflow\V2\KnowledgeAssistAnswer\KnowledgeAnswer\GenerativeSource::class);
        $this->writeOneof(4, $var);

        return $this;
    }

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

}


