<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: google/devtools/cloudtrace/v2/trace.proto

namespace Google\Cloud\Trace\V2\Span;

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

/**
 * A time-stamped annotation or message event in the Span.
 *
 * Generated from protobuf message <code>google.devtools.cloudtrace.v2.Span.TimeEvent</code>
 */
class TimeEvent extends \Google\Protobuf\Internal\Message
{
    /**
     * The timestamp indicating the time the event occurred.
     *
     * Generated from protobuf field <code>.google.protobuf.Timestamp time = 1;</code>
     */
    private $time = null;
    protected $value;

    /**
     * Constructor.
     *
     * @param array $data {
     *     Optional. Data for populating the Message object.
     *
     *     @type \Google\Protobuf\Timestamp $time
     *           The timestamp indicating the time the event occurred.
     *     @type \Google\Cloud\Trace\V2\Span\TimeEvent\Annotation $annotation
     *           Text annotation with a set of attributes.
     *     @type \Google\Cloud\Trace\V2\Span\TimeEvent\MessageEvent $message_event
     *           An event describing a message sent/received between Spans.
     * }
     */
    public function __construct($data = NULL) {
        \GPBMetadata\Google\Devtools\Cloudtrace\V2\Trace::initOnce();
        parent::__construct($data);
    }

    /**
     * The timestamp indicating the time the event occurred.
     *
     * Generated from protobuf field <code>.google.protobuf.Timestamp time = 1;</code>
     * @return \Google\Protobuf\Timestamp
     */
    public function getTime()
    {
        return isset($this->time) ? $this->time : null;
    }

    public function hasTime()
    {
        return isset($this->time);
    }

    public function clearTime()
    {
        unset($this->time);
    }

    /**
     * The timestamp indicating the time the event occurred.
     *
     * Generated from protobuf field <code>.google.protobuf.Timestamp time = 1;</code>
     * @param \Google\Protobuf\Timestamp $var
     * @return $this
     */
    public function setTime($var)
    {
        GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class);
        $this->time = $var;

        return $this;
    }

    /**
     * Text annotation with a set of attributes.
     *
     * Generated from protobuf field <code>.google.devtools.cloudtrace.v2.Span.TimeEvent.Annotation annotation = 2;</code>
     * @return \Google\Cloud\Trace\V2\Span\TimeEvent\Annotation
     */
    public function getAnnotation()
    {
        return $this->readOneof(2);
    }

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

    /**
     * Text annotation with a set of attributes.
     *
     * Generated from protobuf field <code>.google.devtools.cloudtrace.v2.Span.TimeEvent.Annotation annotation = 2;</code>
     * @param \Google\Cloud\Trace\V2\Span\TimeEvent\Annotation $var
     * @return $this
     */
    public function setAnnotation($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\Trace\V2\Span\TimeEvent\Annotation::class);
        $this->writeOneof(2, $var);

        return $this;
    }

    /**
     * An event describing a message sent/received between Spans.
     *
     * Generated from protobuf field <code>.google.devtools.cloudtrace.v2.Span.TimeEvent.MessageEvent message_event = 3;</code>
     * @return \Google\Cloud\Trace\V2\Span\TimeEvent\MessageEvent
     */
    public function getMessageEvent()
    {
        return $this->readOneof(3);
    }

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

    /**
     * An event describing a message sent/received between Spans.
     *
     * Generated from protobuf field <code>.google.devtools.cloudtrace.v2.Span.TimeEvent.MessageEvent message_event = 3;</code>
     * @param \Google\Cloud\Trace\V2\Span\TimeEvent\MessageEvent $var
     * @return $this
     */
    public function setMessageEvent($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\Trace\V2\Span\TimeEvent\MessageEvent::class);
        $this->writeOneof(3, $var);

        return $this;
    }

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

}

// Adding a class alias for backwards compatibility with the previous class name.
class_alias(TimeEvent::class, \Google\Cloud\Trace\V2\Span_TimeEvent::class);

