Source: proto/google/protobuf/duration_pb.js

  1. // source: google/protobuf/duration.proto
  2. /**
  3. * @fileoverview
  4. * @enhanceable
  5. * @suppress {messageConventions} JS Compiler reports an error if a variable or
  6. * field starts with 'MSG_' and isn't a translatable message.
  7. * @public
  8. */
  9. // GENERATED CODE -- DO NOT EDIT!
  10. var jspb = require('google-protobuf');
  11. var goog = jspb;
  12. var global = Function('return this')();
  13. goog.exportSymbol('proto.google.protobuf.Duration', null, global);
  14. /**
  15. * Generated by JsPbCodeGenerator.
  16. * @param {Array=} opt_data Optional initial data array, typically from a
  17. * server response, or constructed directly in Javascript. The array is used
  18. * in place and becomes part of the constructed object. It is not cloned.
  19. * If no data is provided, the constructed object will be empty, but still
  20. * valid.
  21. * @extends {jspb.Message}
  22. * @constructor
  23. */
  24. proto.google.protobuf.Duration = function(opt_data) {
  25. jspb.Message.initialize(this, opt_data, 0, -1, null, null);
  26. };
  27. goog.inherits(proto.google.protobuf.Duration, jspb.Message);
  28. if (goog.DEBUG && !COMPILED) {
  29. /**
  30. * @public
  31. * @override
  32. */
  33. proto.google.protobuf.Duration.displayName = 'proto.google.protobuf.Duration';
  34. }
  35. if (jspb.Message.GENERATE_TO_OBJECT) {
  36. /**
  37. * Creates an object representation of this proto.
  38. * Field names that are reserved in JavaScript and will be renamed to pb_name.
  39. * Optional fields that are not set will be set to undefined.
  40. * To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
  41. * For the list of reserved names please see:
  42. * net/proto2/compiler/js/internal/generator.cc#kKeyword.
  43. * @param {boolean=} opt_includeInstance Deprecated. whether to include the
  44. * JSPB instance for transitional soy proto support:
  45. * http://goto/soy-param-migration
  46. * @return {!Object}
  47. */
  48. proto.google.protobuf.Duration.prototype.toObject = function(opt_includeInstance) {
  49. return proto.google.protobuf.Duration.toObject(opt_includeInstance, this);
  50. };
  51. /**
  52. * Static version of the {@see toObject} method.
  53. * @param {boolean|undefined} includeInstance Deprecated. Whether to include
  54. * the JSPB instance for transitional soy proto support:
  55. * http://goto/soy-param-migration
  56. * @param {!proto.google.protobuf.Duration} msg The msg instance to transform.
  57. * @return {!Object}
  58. * @suppress {unusedLocalVariables} f is only used for nested messages
  59. */
  60. proto.google.protobuf.Duration.toObject = function(includeInstance, msg) {
  61. var f, obj = {
  62. seconds: jspb.Message.getFieldWithDefault(msg, 1, 0),
  63. nanos: jspb.Message.getFieldWithDefault(msg, 2, 0)
  64. };
  65. if (includeInstance) {
  66. obj.$jspbMessageInstance = msg;
  67. }
  68. return obj;
  69. };
  70. }
  71. /**
  72. * Deserializes binary data (in protobuf wire format).
  73. * @param {jspb.ByteSource} bytes The bytes to deserialize.
  74. * @return {!proto.google.protobuf.Duration}
  75. */
  76. proto.google.protobuf.Duration.deserializeBinary = function(bytes) {
  77. var reader = new jspb.BinaryReader(bytes);
  78. var msg = new proto.google.protobuf.Duration;
  79. return proto.google.protobuf.Duration.deserializeBinaryFromReader(msg, reader);
  80. };
  81. /**
  82. * Deserializes binary data (in protobuf wire format) from the
  83. * given reader into the given message object.
  84. * @param {!proto.google.protobuf.Duration} msg The message object to deserialize into.
  85. * @param {!jspb.BinaryReader} reader The BinaryReader to use.
  86. * @return {!proto.google.protobuf.Duration}
  87. */
  88. proto.google.protobuf.Duration.deserializeBinaryFromReader = function(msg, reader) {
  89. while (reader.nextField()) {
  90. if (reader.isEndGroup()) {
  91. break;
  92. }
  93. var field = reader.getFieldNumber();
  94. switch (field) {
  95. case 1:
  96. var value = /** @type {number} */ (reader.readInt64());
  97. msg.setSeconds(value);
  98. break;
  99. case 2:
  100. var value = /** @type {number} */ (reader.readInt32());
  101. msg.setNanos(value);
  102. break;
  103. default:
  104. reader.skipField();
  105. break;
  106. }
  107. }
  108. return msg;
  109. };
  110. /**
  111. * Serializes the message to binary data (in protobuf wire format).
  112. * @return {!Uint8Array}
  113. */
  114. proto.google.protobuf.Duration.prototype.serializeBinary = function() {
  115. var writer = new jspb.BinaryWriter();
  116. proto.google.protobuf.Duration.serializeBinaryToWriter(this, writer);
  117. return writer.getResultBuffer();
  118. };
  119. /**
  120. * Serializes the given message to binary data (in protobuf wire
  121. * format), writing to the given BinaryWriter.
  122. * @param {!proto.google.protobuf.Duration} message
  123. * @param {!jspb.BinaryWriter} writer
  124. * @suppress {unusedLocalVariables} f is only used for nested messages
  125. */
  126. proto.google.protobuf.Duration.serializeBinaryToWriter = function(message, writer) {
  127. var f = undefined;
  128. f = message.getSeconds();
  129. if (f !== 0) {
  130. writer.writeInt64(
  131. 1,
  132. f
  133. );
  134. }
  135. f = message.getNanos();
  136. if (f !== 0) {
  137. writer.writeInt32(
  138. 2,
  139. f
  140. );
  141. }
  142. };
  143. /**
  144. * optional int64 seconds = 1;
  145. * @return {number}
  146. */
  147. proto.google.protobuf.Duration.prototype.getSeconds = function() {
  148. return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0));
  149. };
  150. /**
  151. * @param {number} value
  152. * @return {!proto.google.protobuf.Duration} returns this
  153. */
  154. proto.google.protobuf.Duration.prototype.setSeconds = function(value) {
  155. return jspb.Message.setProto3IntField(this, 1, value);
  156. };
  157. /**
  158. * optional int32 nanos = 2;
  159. * @return {number}
  160. */
  161. proto.google.protobuf.Duration.prototype.getNanos = function() {
  162. return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0));
  163. };
  164. /**
  165. * @param {number} value
  166. * @return {!proto.google.protobuf.Duration} returns this
  167. */
  168. proto.google.protobuf.Duration.prototype.setNanos = function(value) {
  169. return jspb.Message.setProto3IntField(this, 2, value);
  170. };
  171. goog.object.extend(exports, proto.google.protobuf);
  172. // Generated by Spine ProtoJs Plugin
  173. proto.google.protobuf.Duration.typeUrl = function() {
  174. return 'type.googleapis.com/google.protobuf.Duration';
  175. };