// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: tensorflow/core/profiler/protobuf/xplane.proto

package org.tensorflow.proto.profiler;

/**
 * <pre>
 * An XEvent is a trace event, optionally annotated with XStats.
 * Next ID: 6
 * </pre>
 *
 * Protobuf type {@code tensorflow.profiler.XEvent}
 */
public  final class XEvent extends
    com.google.protobuf.GeneratedMessageV3 implements
    // @@protoc_insertion_point(message_implements:tensorflow.profiler.XEvent)
    XEventOrBuilder {
private static final long serialVersionUID = 0L;
  // Use XEvent.newBuilder() to construct.
  private XEvent(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
    super(builder);
  }
  private XEvent() {
    stats_ = java.util.Collections.emptyList();
  }

  @java.lang.Override
  @SuppressWarnings({"unused"})
  protected java.lang.Object newInstance(
      UnusedPrivateParameter unused) {
    return new XEvent();
  }

  @java.lang.Override
  public final com.google.protobuf.UnknownFieldSet
  getUnknownFields() {
    return this.unknownFields;
  }
  private XEvent(
      com.google.protobuf.CodedInputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    this();
    if (extensionRegistry == null) {
      throw new java.lang.NullPointerException();
    }
    int mutable_bitField0_ = 0;
    com.google.protobuf.UnknownFieldSet.Builder unknownFields =
        com.google.protobuf.UnknownFieldSet.newBuilder();
    try {
      boolean done = false;
      while (!done) {
        int tag = input.readTag();
        switch (tag) {
          case 0:
            done = true;
            break;
          case 8: {

            metadataId_ = input.readInt64();
            break;
          }
          case 16: {
            dataCase_ = 2;
            data_ = input.readInt64();
            break;
          }
          case 24: {

            durationPs_ = input.readInt64();
            break;
          }
          case 34: {
            if (!((mutable_bitField0_ & 0x00000001) != 0)) {
              stats_ = new java.util.ArrayList<org.tensorflow.proto.profiler.XStat>();
              mutable_bitField0_ |= 0x00000001;
            }
            stats_.add(
                input.readMessage(org.tensorflow.proto.profiler.XStat.parser(), extensionRegistry));
            break;
          }
          case 40: {
            dataCase_ = 5;
            data_ = input.readInt64();
            break;
          }
          default: {
            if (!parseUnknownField(
                input, unknownFields, extensionRegistry, tag)) {
              done = true;
            }
            break;
          }
        }
      }
    } catch (com.google.protobuf.InvalidProtocolBufferException e) {
      throw e.setUnfinishedMessage(this);
    } catch (java.io.IOException e) {
      throw new com.google.protobuf.InvalidProtocolBufferException(
          e).setUnfinishedMessage(this);
    } finally {
      if (((mutable_bitField0_ & 0x00000001) != 0)) {
        stats_ = java.util.Collections.unmodifiableList(stats_);
      }
      this.unknownFields = unknownFields.build();
      makeExtensionsImmutable();
    }
  }
  public static final com.google.protobuf.Descriptors.Descriptor
      getDescriptor() {
    return org.tensorflow.proto.profiler.XPlaneProtos.internal_static_tensorflow_profiler_XEvent_descriptor;
  }

  @java.lang.Override
  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
      internalGetFieldAccessorTable() {
    return org.tensorflow.proto.profiler.XPlaneProtos.internal_static_tensorflow_profiler_XEvent_fieldAccessorTable
        .ensureFieldAccessorsInitialized(
            org.tensorflow.proto.profiler.XEvent.class, org.tensorflow.proto.profiler.XEvent.Builder.class);
  }

  private int dataCase_ = 0;
  private java.lang.Object data_;
  public enum DataCase
      implements com.google.protobuf.Internal.EnumLite {
    OFFSET_PS(2),
    NUM_OCCURRENCES(5),
    DATA_NOT_SET(0);
    private final int value;
    private DataCase(int value) {
      this.value = value;
    }
    /**
     * @deprecated Use {@link #forNumber(int)} instead.
     */
    @java.lang.Deprecated
    public static DataCase valueOf(int value) {
      return forNumber(value);
    }

    public static DataCase forNumber(int value) {
      switch (value) {
        case 2: return OFFSET_PS;
        case 5: return NUM_OCCURRENCES;
        case 0: return DATA_NOT_SET;
        default: return null;
      }
    }
    public int getNumber() {
      return this.value;
    }
  };

  public DataCase
  getDataCase() {
    return DataCase.forNumber(
        dataCase_);
  }

  public static final int METADATA_ID_FIELD_NUMBER = 1;
  private long metadataId_;
  /**
   * <pre>
   * XEventMetadata.id of corresponding metadata.
   * </pre>
   *
   * <code>int64 metadata_id = 1;</code>
   */
  public long getMetadataId() {
    return metadataId_;
  }

  public static final int OFFSET_PS_FIELD_NUMBER = 2;
  /**
   * <pre>
   * Start time of the event in picoseconds, as offset from
   * XLine.timestamp_ns().
   * </pre>
   *
   * <code>int64 offset_ps = 2;</code>
   */
  public long getOffsetPs() {
    if (dataCase_ == 2) {
      return (java.lang.Long) data_;
    }
    return 0L;
  }

  public static final int NUM_OCCURRENCES_FIELD_NUMBER = 5;
  /**
   * <pre>
   * Number of occurrences of the event, if aggregated.
   * </pre>
   *
   * <code>int64 num_occurrences = 5;</code>
   */
  public long getNumOccurrences() {
    if (dataCase_ == 5) {
      return (java.lang.Long) data_;
    }
    return 0L;
  }

  public static final int DURATION_PS_FIELD_NUMBER = 3;
  private long durationPs_;
  /**
   * <pre>
   * Duration of the event in picoseconds. Can be zero for an instant event.
   * </pre>
   *
   * <code>int64 duration_ps = 3;</code>
   */
  public long getDurationPs() {
    return durationPs_;
  }

  public static final int STATS_FIELD_NUMBER = 4;
  private java.util.List<org.tensorflow.proto.profiler.XStat> stats_;
  /**
   * <pre>
   * XStats associated with the event.
   * Each of these XStats should have a different metadata_id.
   * </pre>
   *
   * <code>repeated .tensorflow.profiler.XStat stats = 4;</code>
   */
  public java.util.List<org.tensorflow.proto.profiler.XStat> getStatsList() {
    return stats_;
  }
  /**
   * <pre>
   * XStats associated with the event.
   * Each of these XStats should have a different metadata_id.
   * </pre>
   *
   * <code>repeated .tensorflow.profiler.XStat stats = 4;</code>
   */
  public java.util.List<? extends org.tensorflow.proto.profiler.XStatOrBuilder> 
      getStatsOrBuilderList() {
    return stats_;
  }
  /**
   * <pre>
   * XStats associated with the event.
   * Each of these XStats should have a different metadata_id.
   * </pre>
   *
   * <code>repeated .tensorflow.profiler.XStat stats = 4;</code>
   */
  public int getStatsCount() {
    return stats_.size();
  }
  /**
   * <pre>
   * XStats associated with the event.
   * Each of these XStats should have a different metadata_id.
   * </pre>
   *
   * <code>repeated .tensorflow.profiler.XStat stats = 4;</code>
   */
  public org.tensorflow.proto.profiler.XStat getStats(int index) {
    return stats_.get(index);
  }
  /**
   * <pre>
   * XStats associated with the event.
   * Each of these XStats should have a different metadata_id.
   * </pre>
   *
   * <code>repeated .tensorflow.profiler.XStat stats = 4;</code>
   */
  public org.tensorflow.proto.profiler.XStatOrBuilder getStatsOrBuilder(
      int index) {
    return stats_.get(index);
  }

  private byte memoizedIsInitialized = -1;
  @java.lang.Override
  public final boolean isInitialized() {
    byte isInitialized = memoizedIsInitialized;
    if (isInitialized == 1) return true;
    if (isInitialized == 0) return false;

    memoizedIsInitialized = 1;
    return true;
  }

  @java.lang.Override
  public void writeTo(com.google.protobuf.CodedOutputStream output)
                      throws java.io.IOException {
    if (metadataId_ != 0L) {
      output.writeInt64(1, metadataId_);
    }
    if (dataCase_ == 2) {
      output.writeInt64(
          2, (long)((java.lang.Long) data_));
    }
    if (durationPs_ != 0L) {
      output.writeInt64(3, durationPs_);
    }
    for (int i = 0; i < stats_.size(); i++) {
      output.writeMessage(4, stats_.get(i));
    }
    if (dataCase_ == 5) {
      output.writeInt64(
          5, (long)((java.lang.Long) data_));
    }
    unknownFields.writeTo(output);
  }

  @java.lang.Override
  public int getSerializedSize() {
    int size = memoizedSize;
    if (size != -1) return size;

    size = 0;
    if (metadataId_ != 0L) {
      size += com.google.protobuf.CodedOutputStream
        .computeInt64Size(1, metadataId_);
    }
    if (dataCase_ == 2) {
      size += com.google.protobuf.CodedOutputStream
        .computeInt64Size(
            2, (long)((java.lang.Long) data_));
    }
    if (durationPs_ != 0L) {
      size += com.google.protobuf.CodedOutputStream
        .computeInt64Size(3, durationPs_);
    }
    for (int i = 0; i < stats_.size(); i++) {
      size += com.google.protobuf.CodedOutputStream
        .computeMessageSize(4, stats_.get(i));
    }
    if (dataCase_ == 5) {
      size += com.google.protobuf.CodedOutputStream
        .computeInt64Size(
            5, (long)((java.lang.Long) data_));
    }
    size += unknownFields.getSerializedSize();
    memoizedSize = size;
    return size;
  }

  @java.lang.Override
  public boolean equals(final java.lang.Object obj) {
    if (obj == this) {
     return true;
    }
    if (!(obj instanceof org.tensorflow.proto.profiler.XEvent)) {
      return super.equals(obj);
    }
    org.tensorflow.proto.profiler.XEvent other = (org.tensorflow.proto.profiler.XEvent) obj;

    if (getMetadataId()
        != other.getMetadataId()) return false;
    if (getDurationPs()
        != other.getDurationPs()) return false;
    if (!getStatsList()
        .equals(other.getStatsList())) return false;
    if (!getDataCase().equals(other.getDataCase())) return false;
    switch (dataCase_) {
      case 2:
        if (getOffsetPs()
            != other.getOffsetPs()) return false;
        break;
      case 5:
        if (getNumOccurrences()
            != other.getNumOccurrences()) return false;
        break;
      case 0:
      default:
    }
    if (!unknownFields.equals(other.unknownFields)) return false;
    return true;
  }

  @java.lang.Override
  public int hashCode() {
    if (memoizedHashCode != 0) {
      return memoizedHashCode;
    }
    int hash = 41;
    hash = (19 * hash) + getDescriptor().hashCode();
    hash = (37 * hash) + METADATA_ID_FIELD_NUMBER;
    hash = (53 * hash) + com.google.protobuf.Internal.hashLong(
        getMetadataId());
    hash = (37 * hash) + DURATION_PS_FIELD_NUMBER;
    hash = (53 * hash) + com.google.protobuf.Internal.hashLong(
        getDurationPs());
    if (getStatsCount() > 0) {
      hash = (37 * hash) + STATS_FIELD_NUMBER;
      hash = (53 * hash) + getStatsList().hashCode();
    }
    switch (dataCase_) {
      case 2:
        hash = (37 * hash) + OFFSET_PS_FIELD_NUMBER;
        hash = (53 * hash) + com.google.protobuf.Internal.hashLong(
            getOffsetPs());
        break;
      case 5:
        hash = (37 * hash) + NUM_OCCURRENCES_FIELD_NUMBER;
        hash = (53 * hash) + com.google.protobuf.Internal.hashLong(
            getNumOccurrences());
        break;
      case 0:
      default:
    }
    hash = (29 * hash) + unknownFields.hashCode();
    memoizedHashCode = hash;
    return hash;
  }

  public static org.tensorflow.proto.profiler.XEvent parseFrom(
      java.nio.ByteBuffer data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }
  public static org.tensorflow.proto.profiler.XEvent parseFrom(
      java.nio.ByteBuffer data,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }
  public static org.tensorflow.proto.profiler.XEvent parseFrom(
      com.google.protobuf.ByteString data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }
  public static org.tensorflow.proto.profiler.XEvent parseFrom(
      com.google.protobuf.ByteString data,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }
  public static org.tensorflow.proto.profiler.XEvent parseFrom(byte[] data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }
  public static org.tensorflow.proto.profiler.XEvent parseFrom(
      byte[] data,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }
  public static org.tensorflow.proto.profiler.XEvent parseFrom(java.io.InputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseWithIOException(PARSER, input);
  }
  public static org.tensorflow.proto.profiler.XEvent parseFrom(
      java.io.InputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseWithIOException(PARSER, input, extensionRegistry);
  }
  public static org.tensorflow.proto.profiler.XEvent parseDelimitedFrom(java.io.InputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseDelimitedWithIOException(PARSER, input);
  }
  public static org.tensorflow.proto.profiler.XEvent parseDelimitedFrom(
      java.io.InputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
  }
  public static org.tensorflow.proto.profiler.XEvent parseFrom(
      com.google.protobuf.CodedInputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseWithIOException(PARSER, input);
  }
  public static org.tensorflow.proto.profiler.XEvent parseFrom(
      com.google.protobuf.CodedInputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseWithIOException(PARSER, input, extensionRegistry);
  }

  @java.lang.Override
  public Builder newBuilderForType() { return newBuilder(); }
  public static Builder newBuilder() {
    return DEFAULT_INSTANCE.toBuilder();
  }
  public static Builder newBuilder(org.tensorflow.proto.profiler.XEvent prototype) {
    return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
  }
  @java.lang.Override
  public Builder toBuilder() {
    return this == DEFAULT_INSTANCE
        ? new Builder() : new Builder().mergeFrom(this);
  }

  @java.lang.Override
  protected Builder newBuilderForType(
      com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
    Builder builder = new Builder(parent);
    return builder;
  }
  /**
   * <pre>
   * An XEvent is a trace event, optionally annotated with XStats.
   * Next ID: 6
   * </pre>
   *
   * Protobuf type {@code tensorflow.profiler.XEvent}
   */
  public static final class Builder extends
      com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
      // @@protoc_insertion_point(builder_implements:tensorflow.profiler.XEvent)
      org.tensorflow.proto.profiler.XEventOrBuilder {
    public static final com.google.protobuf.Descriptors.Descriptor
        getDescriptor() {
      return org.tensorflow.proto.profiler.XPlaneProtos.internal_static_tensorflow_profiler_XEvent_descriptor;
    }

    @java.lang.Override
    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
        internalGetFieldAccessorTable() {
      return org.tensorflow.proto.profiler.XPlaneProtos.internal_static_tensorflow_profiler_XEvent_fieldAccessorTable
          .ensureFieldAccessorsInitialized(
              org.tensorflow.proto.profiler.XEvent.class, org.tensorflow.proto.profiler.XEvent.Builder.class);
    }

    // Construct using org.tensorflow.proto.profiler.XEvent.newBuilder()
    private Builder() {
      maybeForceBuilderInitialization();
    }

    private Builder(
        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
      super(parent);
      maybeForceBuilderInitialization();
    }
    private void maybeForceBuilderInitialization() {
      if (com.google.protobuf.GeneratedMessageV3
              .alwaysUseFieldBuilders) {
        getStatsFieldBuilder();
      }
    }
    @java.lang.Override
    public Builder clear() {
      super.clear();
      metadataId_ = 0L;

      durationPs_ = 0L;

      if (statsBuilder_ == null) {
        stats_ = java.util.Collections.emptyList();
        bitField0_ = (bitField0_ & ~0x00000001);
      } else {
        statsBuilder_.clear();
      }
      dataCase_ = 0;
      data_ = null;
      return this;
    }

    @java.lang.Override
    public com.google.protobuf.Descriptors.Descriptor
        getDescriptorForType() {
      return org.tensorflow.proto.profiler.XPlaneProtos.internal_static_tensorflow_profiler_XEvent_descriptor;
    }

    @java.lang.Override
    public org.tensorflow.proto.profiler.XEvent getDefaultInstanceForType() {
      return org.tensorflow.proto.profiler.XEvent.getDefaultInstance();
    }

    @java.lang.Override
    public org.tensorflow.proto.profiler.XEvent build() {
      org.tensorflow.proto.profiler.XEvent result = buildPartial();
      if (!result.isInitialized()) {
        throw newUninitializedMessageException(result);
      }
      return result;
    }

    @java.lang.Override
    public org.tensorflow.proto.profiler.XEvent buildPartial() {
      org.tensorflow.proto.profiler.XEvent result = new org.tensorflow.proto.profiler.XEvent(this);
      int from_bitField0_ = bitField0_;
      result.metadataId_ = metadataId_;
      if (dataCase_ == 2) {
        result.data_ = data_;
      }
      if (dataCase_ == 5) {
        result.data_ = data_;
      }
      result.durationPs_ = durationPs_;
      if (statsBuilder_ == null) {
        if (((bitField0_ & 0x00000001) != 0)) {
          stats_ = java.util.Collections.unmodifiableList(stats_);
          bitField0_ = (bitField0_ & ~0x00000001);
        }
        result.stats_ = stats_;
      } else {
        result.stats_ = statsBuilder_.build();
      }
      result.dataCase_ = dataCase_;
      onBuilt();
      return result;
    }

    @java.lang.Override
    public Builder clone() {
      return super.clone();
    }
    @java.lang.Override
    public Builder setField(
        com.google.protobuf.Descriptors.FieldDescriptor field,
        java.lang.Object value) {
      return super.setField(field, value);
    }
    @java.lang.Override
    public Builder clearField(
        com.google.protobuf.Descriptors.FieldDescriptor field) {
      return super.clearField(field);
    }
    @java.lang.Override
    public Builder clearOneof(
        com.google.protobuf.Descriptors.OneofDescriptor oneof) {
      return super.clearOneof(oneof);
    }
    @java.lang.Override
    public Builder setRepeatedField(
        com.google.protobuf.Descriptors.FieldDescriptor field,
        int index, java.lang.Object value) {
      return super.setRepeatedField(field, index, value);
    }
    @java.lang.Override
    public Builder addRepeatedField(
        com.google.protobuf.Descriptors.FieldDescriptor field,
        java.lang.Object value) {
      return super.addRepeatedField(field, value);
    }
    @java.lang.Override
    public Builder mergeFrom(com.google.protobuf.Message other) {
      if (other instanceof org.tensorflow.proto.profiler.XEvent) {
        return mergeFrom((org.tensorflow.proto.profiler.XEvent)other);
      } else {
        super.mergeFrom(other);
        return this;
      }
    }

    public Builder mergeFrom(org.tensorflow.proto.profiler.XEvent other) {
      if (other == org.tensorflow.proto.profiler.XEvent.getDefaultInstance()) return this;
      if (other.getMetadataId() != 0L) {
        setMetadataId(other.getMetadataId());
      }
      if (other.getDurationPs() != 0L) {
        setDurationPs(other.getDurationPs());
      }
      if (statsBuilder_ == null) {
        if (!other.stats_.isEmpty()) {
          if (stats_.isEmpty()) {
            stats_ = other.stats_;
            bitField0_ = (bitField0_ & ~0x00000001);
          } else {
            ensureStatsIsMutable();
            stats_.addAll(other.stats_);
          }
          onChanged();
        }
      } else {
        if (!other.stats_.isEmpty()) {
          if (statsBuilder_.isEmpty()) {
            statsBuilder_.dispose();
            statsBuilder_ = null;
            stats_ = other.stats_;
            bitField0_ = (bitField0_ & ~0x00000001);
            statsBuilder_ = 
              com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
                 getStatsFieldBuilder() : null;
          } else {
            statsBuilder_.addAllMessages(other.stats_);
          }
        }
      }
      switch (other.getDataCase()) {
        case OFFSET_PS: {
          setOffsetPs(other.getOffsetPs());
          break;
        }
        case NUM_OCCURRENCES: {
          setNumOccurrences(other.getNumOccurrences());
          break;
        }
        case DATA_NOT_SET: {
          break;
        }
      }
      this.mergeUnknownFields(other.unknownFields);
      onChanged();
      return this;
    }

    @java.lang.Override
    public final boolean isInitialized() {
      return true;
    }

    @java.lang.Override
    public Builder mergeFrom(
        com.google.protobuf.CodedInputStream input,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws java.io.IOException {
      org.tensorflow.proto.profiler.XEvent parsedMessage = null;
      try {
        parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
      } catch (com.google.protobuf.InvalidProtocolBufferException e) {
        parsedMessage = (org.tensorflow.proto.profiler.XEvent) e.getUnfinishedMessage();
        throw e.unwrapIOException();
      } finally {
        if (parsedMessage != null) {
          mergeFrom(parsedMessage);
        }
      }
      return this;
    }
    private int dataCase_ = 0;
    private java.lang.Object data_;
    public DataCase
        getDataCase() {
      return DataCase.forNumber(
          dataCase_);
    }

    public Builder clearData() {
      dataCase_ = 0;
      data_ = null;
      onChanged();
      return this;
    }

    private int bitField0_;

    private long metadataId_ ;
    /**
     * <pre>
     * XEventMetadata.id of corresponding metadata.
     * </pre>
     *
     * <code>int64 metadata_id = 1;</code>
     */
    public long getMetadataId() {
      return metadataId_;
    }
    /**
     * <pre>
     * XEventMetadata.id of corresponding metadata.
     * </pre>
     *
     * <code>int64 metadata_id = 1;</code>
     */
    public Builder setMetadataId(long value) {
      
      metadataId_ = value;
      onChanged();
      return this;
    }
    /**
     * <pre>
     * XEventMetadata.id of corresponding metadata.
     * </pre>
     *
     * <code>int64 metadata_id = 1;</code>
     */
    public Builder clearMetadataId() {
      
      metadataId_ = 0L;
      onChanged();
      return this;
    }

    /**
     * <pre>
     * Start time of the event in picoseconds, as offset from
     * XLine.timestamp_ns().
     * </pre>
     *
     * <code>int64 offset_ps = 2;</code>
     */
    public long getOffsetPs() {
      if (dataCase_ == 2) {
        return (java.lang.Long) data_;
      }
      return 0L;
    }
    /**
     * <pre>
     * Start time of the event in picoseconds, as offset from
     * XLine.timestamp_ns().
     * </pre>
     *
     * <code>int64 offset_ps = 2;</code>
     */
    public Builder setOffsetPs(long value) {
      dataCase_ = 2;
      data_ = value;
      onChanged();
      return this;
    }
    /**
     * <pre>
     * Start time of the event in picoseconds, as offset from
     * XLine.timestamp_ns().
     * </pre>
     *
     * <code>int64 offset_ps = 2;</code>
     */
    public Builder clearOffsetPs() {
      if (dataCase_ == 2) {
        dataCase_ = 0;
        data_ = null;
        onChanged();
      }
      return this;
    }

    /**
     * <pre>
     * Number of occurrences of the event, if aggregated.
     * </pre>
     *
     * <code>int64 num_occurrences = 5;</code>
     */
    public long getNumOccurrences() {
      if (dataCase_ == 5) {
        return (java.lang.Long) data_;
      }
      return 0L;
    }
    /**
     * <pre>
     * Number of occurrences of the event, if aggregated.
     * </pre>
     *
     * <code>int64 num_occurrences = 5;</code>
     */
    public Builder setNumOccurrences(long value) {
      dataCase_ = 5;
      data_ = value;
      onChanged();
      return this;
    }
    /**
     * <pre>
     * Number of occurrences of the event, if aggregated.
     * </pre>
     *
     * <code>int64 num_occurrences = 5;</code>
     */
    public Builder clearNumOccurrences() {
      if (dataCase_ == 5) {
        dataCase_ = 0;
        data_ = null;
        onChanged();
      }
      return this;
    }

    private long durationPs_ ;
    /**
     * <pre>
     * Duration of the event in picoseconds. Can be zero for an instant event.
     * </pre>
     *
     * <code>int64 duration_ps = 3;</code>
     */
    public long getDurationPs() {
      return durationPs_;
    }
    /**
     * <pre>
     * Duration of the event in picoseconds. Can be zero for an instant event.
     * </pre>
     *
     * <code>int64 duration_ps = 3;</code>
     */
    public Builder setDurationPs(long value) {
      
      durationPs_ = value;
      onChanged();
      return this;
    }
    /**
     * <pre>
     * Duration of the event in picoseconds. Can be zero for an instant event.
     * </pre>
     *
     * <code>int64 duration_ps = 3;</code>
     */
    public Builder clearDurationPs() {
      
      durationPs_ = 0L;
      onChanged();
      return this;
    }

    private java.util.List<org.tensorflow.proto.profiler.XStat> stats_ =
      java.util.Collections.emptyList();
    private void ensureStatsIsMutable() {
      if (!((bitField0_ & 0x00000001) != 0)) {
        stats_ = new java.util.ArrayList<org.tensorflow.proto.profiler.XStat>(stats_);
        bitField0_ |= 0x00000001;
       }
    }

    private com.google.protobuf.RepeatedFieldBuilderV3<
        org.tensorflow.proto.profiler.XStat, org.tensorflow.proto.profiler.XStat.Builder, org.tensorflow.proto.profiler.XStatOrBuilder> statsBuilder_;

    /**
     * <pre>
     * XStats associated with the event.
     * Each of these XStats should have a different metadata_id.
     * </pre>
     *
     * <code>repeated .tensorflow.profiler.XStat stats = 4;</code>
     */
    public java.util.List<org.tensorflow.proto.profiler.XStat> getStatsList() {
      if (statsBuilder_ == null) {
        return java.util.Collections.unmodifiableList(stats_);
      } else {
        return statsBuilder_.getMessageList();
      }
    }
    /**
     * <pre>
     * XStats associated with the event.
     * Each of these XStats should have a different metadata_id.
     * </pre>
     *
     * <code>repeated .tensorflow.profiler.XStat stats = 4;</code>
     */
    public int getStatsCount() {
      if (statsBuilder_ == null) {
        return stats_.size();
      } else {
        return statsBuilder_.getCount();
      }
    }
    /**
     * <pre>
     * XStats associated with the event.
     * Each of these XStats should have a different metadata_id.
     * </pre>
     *
     * <code>repeated .tensorflow.profiler.XStat stats = 4;</code>
     */
    public org.tensorflow.proto.profiler.XStat getStats(int index) {
      if (statsBuilder_ == null) {
        return stats_.get(index);
      } else {
        return statsBuilder_.getMessage(index);
      }
    }
    /**
     * <pre>
     * XStats associated with the event.
     * Each of these XStats should have a different metadata_id.
     * </pre>
     *
     * <code>repeated .tensorflow.profiler.XStat stats = 4;</code>
     */
    public Builder setStats(
        int index, org.tensorflow.proto.profiler.XStat value) {
      if (statsBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureStatsIsMutable();
        stats_.set(index, value);
        onChanged();
      } else {
        statsBuilder_.setMessage(index, value);
      }
      return this;
    }
    /**
     * <pre>
     * XStats associated with the event.
     * Each of these XStats should have a different metadata_id.
     * </pre>
     *
     * <code>repeated .tensorflow.profiler.XStat stats = 4;</code>
     */
    public Builder setStats(
        int index, org.tensorflow.proto.profiler.XStat.Builder builderForValue) {
      if (statsBuilder_ == null) {
        ensureStatsIsMutable();
        stats_.set(index, builderForValue.build());
        onChanged();
      } else {
        statsBuilder_.setMessage(index, builderForValue.build());
      }
      return this;
    }
    /**
     * <pre>
     * XStats associated with the event.
     * Each of these XStats should have a different metadata_id.
     * </pre>
     *
     * <code>repeated .tensorflow.profiler.XStat stats = 4;</code>
     */
    public Builder addStats(org.tensorflow.proto.profiler.XStat value) {
      if (statsBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureStatsIsMutable();
        stats_.add(value);
        onChanged();
      } else {
        statsBuilder_.addMessage(value);
      }
      return this;
    }
    /**
     * <pre>
     * XStats associated with the event.
     * Each of these XStats should have a different metadata_id.
     * </pre>
     *
     * <code>repeated .tensorflow.profiler.XStat stats = 4;</code>
     */
    public Builder addStats(
        int index, org.tensorflow.proto.profiler.XStat value) {
      if (statsBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureStatsIsMutable();
        stats_.add(index, value);
        onChanged();
      } else {
        statsBuilder_.addMessage(index, value);
      }
      return this;
    }
    /**
     * <pre>
     * XStats associated with the event.
     * Each of these XStats should have a different metadata_id.
     * </pre>
     *
     * <code>repeated .tensorflow.profiler.XStat stats = 4;</code>
     */
    public Builder addStats(
        org.tensorflow.proto.profiler.XStat.Builder builderForValue) {
      if (statsBuilder_ == null) {
        ensureStatsIsMutable();
        stats_.add(builderForValue.build());
        onChanged();
      } else {
        statsBuilder_.addMessage(builderForValue.build());
      }
      return this;
    }
    /**
     * <pre>
     * XStats associated with the event.
     * Each of these XStats should have a different metadata_id.
     * </pre>
     *
     * <code>repeated .tensorflow.profiler.XStat stats = 4;</code>
     */
    public Builder addStats(
        int index, org.tensorflow.proto.profiler.XStat.Builder builderForValue) {
      if (statsBuilder_ == null) {
        ensureStatsIsMutable();
        stats_.add(index, builderForValue.build());
        onChanged();
      } else {
        statsBuilder_.addMessage(index, builderForValue.build());
      }
      return this;
    }
    /**
     * <pre>
     * XStats associated with the event.
     * Each of these XStats should have a different metadata_id.
     * </pre>
     *
     * <code>repeated .tensorflow.profiler.XStat stats = 4;</code>
     */
    public Builder addAllStats(
        java.lang.Iterable<? extends org.tensorflow.proto.profiler.XStat> values) {
      if (statsBuilder_ == null) {
        ensureStatsIsMutable();
        com.google.protobuf.AbstractMessageLite.Builder.addAll(
            values, stats_);
        onChanged();
      } else {
        statsBuilder_.addAllMessages(values);
      }
      return this;
    }
    /**
     * <pre>
     * XStats associated with the event.
     * Each of these XStats should have a different metadata_id.
     * </pre>
     *
     * <code>repeated .tensorflow.profiler.XStat stats = 4;</code>
     */
    public Builder clearStats() {
      if (statsBuilder_ == null) {
        stats_ = java.util.Collections.emptyList();
        bitField0_ = (bitField0_ & ~0x00000001);
        onChanged();
      } else {
        statsBuilder_.clear();
      }
      return this;
    }
    /**
     * <pre>
     * XStats associated with the event.
     * Each of these XStats should have a different metadata_id.
     * </pre>
     *
     * <code>repeated .tensorflow.profiler.XStat stats = 4;</code>
     */
    public Builder removeStats(int index) {
      if (statsBuilder_ == null) {
        ensureStatsIsMutable();
        stats_.remove(index);
        onChanged();
      } else {
        statsBuilder_.remove(index);
      }
      return this;
    }
    /**
     * <pre>
     * XStats associated with the event.
     * Each of these XStats should have a different metadata_id.
     * </pre>
     *
     * <code>repeated .tensorflow.profiler.XStat stats = 4;</code>
     */
    public org.tensorflow.proto.profiler.XStat.Builder getStatsBuilder(
        int index) {
      return getStatsFieldBuilder().getBuilder(index);
    }
    /**
     * <pre>
     * XStats associated with the event.
     * Each of these XStats should have a different metadata_id.
     * </pre>
     *
     * <code>repeated .tensorflow.profiler.XStat stats = 4;</code>
     */
    public org.tensorflow.proto.profiler.XStatOrBuilder getStatsOrBuilder(
        int index) {
      if (statsBuilder_ == null) {
        return stats_.get(index);  } else {
        return statsBuilder_.getMessageOrBuilder(index);
      }
    }
    /**
     * <pre>
     * XStats associated with the event.
     * Each of these XStats should have a different metadata_id.
     * </pre>
     *
     * <code>repeated .tensorflow.profiler.XStat stats = 4;</code>
     */
    public java.util.List<? extends org.tensorflow.proto.profiler.XStatOrBuilder> 
         getStatsOrBuilderList() {
      if (statsBuilder_ != null) {
        return statsBuilder_.getMessageOrBuilderList();
      } else {
        return java.util.Collections.unmodifiableList(stats_);
      }
    }
    /**
     * <pre>
     * XStats associated with the event.
     * Each of these XStats should have a different metadata_id.
     * </pre>
     *
     * <code>repeated .tensorflow.profiler.XStat stats = 4;</code>
     */
    public org.tensorflow.proto.profiler.XStat.Builder addStatsBuilder() {
      return getStatsFieldBuilder().addBuilder(
          org.tensorflow.proto.profiler.XStat.getDefaultInstance());
    }
    /**
     * <pre>
     * XStats associated with the event.
     * Each of these XStats should have a different metadata_id.
     * </pre>
     *
     * <code>repeated .tensorflow.profiler.XStat stats = 4;</code>
     */
    public org.tensorflow.proto.profiler.XStat.Builder addStatsBuilder(
        int index) {
      return getStatsFieldBuilder().addBuilder(
          index, org.tensorflow.proto.profiler.XStat.getDefaultInstance());
    }
    /**
     * <pre>
     * XStats associated with the event.
     * Each of these XStats should have a different metadata_id.
     * </pre>
     *
     * <code>repeated .tensorflow.profiler.XStat stats = 4;</code>
     */
    public java.util.List<org.tensorflow.proto.profiler.XStat.Builder> 
         getStatsBuilderList() {
      return getStatsFieldBuilder().getBuilderList();
    }
    private com.google.protobuf.RepeatedFieldBuilderV3<
        org.tensorflow.proto.profiler.XStat, org.tensorflow.proto.profiler.XStat.Builder, org.tensorflow.proto.profiler.XStatOrBuilder> 
        getStatsFieldBuilder() {
      if (statsBuilder_ == null) {
        statsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
            org.tensorflow.proto.profiler.XStat, org.tensorflow.proto.profiler.XStat.Builder, org.tensorflow.proto.profiler.XStatOrBuilder>(
                stats_,
                ((bitField0_ & 0x00000001) != 0),
                getParentForChildren(),
                isClean());
        stats_ = null;
      }
      return statsBuilder_;
    }
    @java.lang.Override
    public final Builder setUnknownFields(
        final com.google.protobuf.UnknownFieldSet unknownFields) {
      return super.setUnknownFields(unknownFields);
    }

    @java.lang.Override
    public final Builder mergeUnknownFields(
        final com.google.protobuf.UnknownFieldSet unknownFields) {
      return super.mergeUnknownFields(unknownFields);
    }


    // @@protoc_insertion_point(builder_scope:tensorflow.profiler.XEvent)
  }

  // @@protoc_insertion_point(class_scope:tensorflow.profiler.XEvent)
  private static final org.tensorflow.proto.profiler.XEvent DEFAULT_INSTANCE;
  static {
    DEFAULT_INSTANCE = new org.tensorflow.proto.profiler.XEvent();
  }

  public static org.tensorflow.proto.profiler.XEvent getDefaultInstance() {
    return DEFAULT_INSTANCE;
  }

  private static final com.google.protobuf.Parser<XEvent>
      PARSER = new com.google.protobuf.AbstractParser<XEvent>() {
    @java.lang.Override
    public XEvent parsePartialFrom(
        com.google.protobuf.CodedInputStream input,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws com.google.protobuf.InvalidProtocolBufferException {
      return new XEvent(input, extensionRegistry);
    }
  };

  public static com.google.protobuf.Parser<XEvent> parser() {
    return PARSER;
  }

  @java.lang.Override
  public com.google.protobuf.Parser<XEvent> getParserForType() {
    return PARSER;
  }

  @java.lang.Override
  public org.tensorflow.proto.profiler.XEvent getDefaultInstanceForType() {
    return DEFAULT_INSTANCE;
  }

}

