id !== null; } /** * Get 'id' value * * @return \Protobuf\Stream */ public function getId() { return $this->id; } /** * Set 'id' value * * @param \Protobuf\Stream $value */ public function setId($value = null) { if ($value !== null && ! $value instanceof \Protobuf\Stream) { $value = \Protobuf\Stream::wrap($value); } $this->id = $value; } /** * Check if 'body' has a value * * @return bool */ public function hasBody() { return $this->body !== null; } /** * Get 'body' value * * @return string */ public function getBody() { return $this->body; } /** * Set 'body' value * * @param string $value */ public function setBody($value = null) { $this->body = $value; } /** * Check if 'expiry' has a value * * @return bool */ public function hasExpiry() { return $this->expiry !== null; } /** * Get 'expiry' value * * @return int */ public function getExpiry() { return $this->expiry; } /** * Set 'expiry' value * * @param int $value */ public function setExpiry($value = null) { $this->expiry = $value; } /** * Check if 'created' has a value * * @return bool */ public function hasCreated() { return $this->created !== null; } /** * Get 'created' value * * @return int */ public function getCreated() { return $this->created; } /** * Set 'created' value * * @param int $value */ public function setCreated($value = null) { $this->created = $value; } /** * Check if 'sender' has a value * * @return bool */ public function hasSender() { return $this->sender !== null; } /** * Get 'sender' value * * @return \Bitrix\Pull\Protobuf\Sender */ public function getSender() { return $this->sender; } /** * Set 'sender' value * * @param \Bitrix\Pull\Protobuf\Sender $value */ public function setSender(\Bitrix\Pull\Protobuf\Sender $value = null) { $this->sender = $value; } /** * {@inheritdoc} */ public function extensions() { if ( $this->extensions !== null) { return $this->extensions; } return $this->extensions = new \Protobuf\Extension\ExtensionFieldMap(__CLASS__); } /** * {@inheritdoc} */ public function unknownFieldSet() { return $this->unknownFieldSet; } /** * {@inheritdoc} */ public static function fromStream($stream, \Protobuf\Configuration $configuration = null) { return new self($stream, $configuration); } /** * {@inheritdoc} */ public static function fromArray(array $values) { $message = new self(); $values = array_merge([ 'id' => null, 'body' => null, 'expiry' => null, 'created' => null, 'sender' => null ], $values); $message->setId($values['id']); $message->setBody($values['body']); $message->setExpiry($values['expiry']); $message->setCreated($values['created']); $message->setSender($values['sender']); return $message; } /** * {@inheritdoc} */ public static function descriptor() { return \google\protobuf\DescriptorProto::fromArray([ 'name' => 'OutgoingMessage', 'field' => [ \google\protobuf\FieldDescriptorProto::fromArray([ 'number' => 1, 'name' => 'id', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_BYTES(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL() ]), \google\protobuf\FieldDescriptorProto::fromArray([ 'number' => 2, 'name' => 'body', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_STRING(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL() ]), \google\protobuf\FieldDescriptorProto::fromArray([ 'number' => 3, 'name' => 'expiry', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_UINT32(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL() ]), \google\protobuf\FieldDescriptorProto::fromArray([ 'number' => 4, 'name' => 'created', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_FIXED32(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL() ]), \google\protobuf\FieldDescriptorProto::fromArray([ 'number' => 5, 'name' => 'sender', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_MESSAGE(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL(), 'type_name' => '.Sender' ]), ], ]); } /** * {@inheritdoc} */ public function toStream(\Protobuf\Configuration $configuration = null) { $config = $configuration ?: \Protobuf\Configuration::getInstance(); $context = $config->createWriteContext(); $stream = $context->getStream(); $this->writeTo($context); $stream->seek(0); return $stream; } /** * {@inheritdoc} */ public function writeTo(\Protobuf\WriteContext $context) { $stream = $context->getStream(); $writer = $context->getWriter(); $sizeContext = $context->getComputeSizeContext(); if ($this->id !== null) { $writer->writeVarint($stream, 10); $writer->writeByteStream($stream, $this->id); } if ($this->body !== null) { $writer->writeVarint($stream, 18); $writer->writeString($stream, $this->body); } if ($this->expiry !== null) { $writer->writeVarint($stream, 24); $writer->writeVarint($stream, $this->expiry); } if ($this->created !== null) { $writer->writeVarint($stream, 37); $writer->writeFixed32($stream, $this->created); } if ($this->sender !== null) { $writer->writeVarint($stream, 42); $writer->writeVarint($stream, $this->sender->serializedSize($sizeContext)); $this->sender->writeTo($context); } if ($this->extensions !== null) { $this->extensions->writeTo($context); } return $stream; } /** * {@inheritdoc} */ public function readFrom(\Protobuf\ReadContext $context) { $reader = $context->getReader(); $length = $context->getLength(); $stream = $context->getStream(); $limit = ($length !== null) ? ($stream->tell() + $length) : null; while ($limit === null || $stream->tell() < $limit) { if ($stream->eof()) { break; } $key = $reader->readVarint($stream); $wire = \Protobuf\WireFormat::getTagWireType($key); $tag = \Protobuf\WireFormat::getTagFieldNumber($key); if ($stream->eof()) { break; } if ($tag === 1) { \Protobuf\WireFormat::assertWireType($wire, 12); $this->id = $reader->readByteStream($stream); continue; } if ($tag === 2) { \Protobuf\WireFormat::assertWireType($wire, 9); $this->body = $reader->readString($stream); continue; } if ($tag === 3) { \Protobuf\WireFormat::assertWireType($wire, 13); $this->expiry = $reader->readVarint($stream); continue; } if ($tag === 4) { \Protobuf\WireFormat::assertWireType($wire, 7); $this->created = $reader->readFixed32($stream); continue; } if ($tag === 5) { \Protobuf\WireFormat::assertWireType($wire, 11); $innerSize = $reader->readVarint($stream); $innerMessage = new \Bitrix\Pull\Protobuf\Sender(); $this->sender = $innerMessage; $context->setLength($innerSize); $innerMessage->readFrom($context); $context->setLength($length); continue; } $extensions = $context->getExtensionRegistry(); $extension = $extensions ? $extensions->findByNumber(__CLASS__, $tag) : null; if ($extension !== null) { $this->extensions()->add($extension, $extension->readFrom($context, $wire)); continue; } if ($this->unknownFieldSet === null) { $this->unknownFieldSet = new \Protobuf\UnknownFieldSet(); } $data = $reader->readUnknown($stream, $wire); $unknown = new \Protobuf\Unknown($tag, $wire, $data); $this->unknownFieldSet->add($unknown); } } /** * {@inheritdoc} */ public function serializedSize(\Protobuf\ComputeSizeContext $context) { $calculator = $context->getSizeCalculator(); $size = 0; if ($this->id !== null) { $size += 1; $size += $calculator->computeByteStreamSize($this->id); } if ($this->body !== null) { $size += 1; $size += $calculator->computeStringSize($this->body); } if ($this->expiry !== null) { $size += 1; $size += $calculator->computeVarintSize($this->expiry); } if ($this->created !== null) { $size += 1; $size += 4; } if ($this->sender !== null) { $innerSize = $this->sender->serializedSize($context); $size += 1; $size += $innerSize; $size += $calculator->computeVarintSize($innerSize); } if ($this->extensions !== null) { $size += $this->extensions->serializedSize($context); } return $size; } /** * {@inheritdoc} */ public function clear() { $this->id = null; $this->body = null; $this->expiry = null; $this->created = null; $this->sender = null; } /** * {@inheritdoc} */ public function merge(\Protobuf\Message $message) { if ( ! $message instanceof \Bitrix\Pull\Protobuf\OutgoingMessage) { throw new \InvalidArgumentException(sprintf('Argument 1 passed to %s must be a %s, %s given', __METHOD__, __CLASS__, get_class($message))); } $this->id = ($message->id !== null) ? $message->id : $this->id; $this->body = ($message->body !== null) ? $message->body : $this->body; $this->expiry = ($message->expiry !== null) ? $message->expiry : $this->expiry; $this->created = ($message->created !== null) ? $message->created : $this->created; $this->sender = ($message->sender !== null) ? $message->sender : $this->sender; } }