• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/**
2 * @fileoverview Handwritten code of ConformanceRequest.
3 */
4goog.module('proto.conformance.ConformanceRequest');
5
6const Kernel = goog.require('protobuf.runtime.Kernel');
7const WireFormat = goog.require('proto.conformance.WireFormat');
8
9/**
10 * Handwritten code of conformance.ConformanceRequest.
11 * This is used to send request from the conformance test runner to the testee.
12 * Check //third_party/protobuf/testing/protobuf/conformance/conformance.proto
13 * for more details.
14 * @final
15 */
16class ConformanceRequest {
17  /**
18   * @param {!ArrayBuffer} bytes
19   * @private
20   */
21  constructor(bytes) {
22    /** @private @const {!Kernel} */
23    this.accessor_ = Kernel.fromArrayBuffer(bytes);
24  }
25
26  /**
27   * Create a request instance with the given bytes data.
28   * @param {!ArrayBuffer} bytes
29   * @return {!ConformanceRequest}
30   */
31  static deserialize(bytes) {
32    return new ConformanceRequest(bytes);
33  }
34
35  /**
36   * Gets the protobuf_payload.
37   * @return {!ArrayBuffer}
38   */
39  getProtobufPayload() {
40    return this.accessor_.getBytesWithDefault(1).toArrayBuffer();
41  }
42
43  /**
44   * Gets the requested_output_format.
45   * @return {!WireFormat}
46   */
47  getRequestedOutputFormat() {
48    return /** @type {!WireFormat} */ (this.accessor_.getInt32WithDefault(3));
49  }
50
51  /**
52   * Gets the message_type.
53   * @return {string}
54   */
55  getMessageType() {
56    return this.accessor_.getStringWithDefault(4);
57  }
58
59  /**
60   * Gets the oneof case for payload field.
61   * This implementation assumes only one field in a oneof group is set.
62   * @return {!ConformanceRequest.PayloadCase}
63   */
64  getPayloadCase() {
65    if (this.accessor_.hasFieldNumber(1)) {
66      return /** @type {!ConformanceRequest.PayloadCase} */ (
67          ConformanceRequest.PayloadCase.PROTOBUF_PAYLOAD);
68    } else if (this.accessor_.hasFieldNumber(2)) {
69      return /** @type {!ConformanceRequest.PayloadCase} */ (
70          ConformanceRequest.PayloadCase.JSON_PAYLOAD);
71    } else if (this.accessor_.hasFieldNumber(8)) {
72      return /** @type {!ConformanceRequest.PayloadCase} */ (
73          ConformanceRequest.PayloadCase.TEXT_PAYLOAD);
74    } else {
75      return /** @type {!ConformanceRequest.PayloadCase} */ (
76          ConformanceRequest.PayloadCase.PAYLOAD_NOT_SET);
77    }
78  }
79}
80
81/**
82 * @enum {number}
83 */
84ConformanceRequest.PayloadCase = {
85  PAYLOAD_NOT_SET: 0,
86  PROTOBUF_PAYLOAD: 1,
87  JSON_PAYLOAD: 2,
88  TEXT_PAYLOAD: 8,
89};
90
91exports = ConformanceRequest;
92