// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: tribuo-clustering-kmeans.proto

package org.tribuo.clustering.kmeans.protos;

/**
 * <pre>
 *KMeansModel proto
 * </pre>
 *
 * Protobuf type {@code tribuo.clustering.kmeans.KMeansModelProto}
 */
public final class KMeansModelProto extends
    com.google.protobuf.GeneratedMessageV3 implements
    // @@protoc_insertion_point(message_implements:tribuo.clustering.kmeans.KMeansModelProto)
    KMeansModelProtoOrBuilder {
private static final long serialVersionUID = 0L;
  // Use KMeansModelProto.newBuilder() to construct.
  private KMeansModelProto(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
    super(builder);
  }
  private KMeansModelProto() {
    centroidVectors_ = java.util.Collections.emptyList();
  }

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

  @java.lang.Override
  public final com.google.protobuf.UnknownFieldSet
  getUnknownFields() {
    return this.unknownFields;
  }
  private KMeansModelProto(
      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 10: {
            org.tribuo.protos.core.ModelDataProto.Builder subBuilder = null;
            if (metadata_ != null) {
              subBuilder = metadata_.toBuilder();
            }
            metadata_ = input.readMessage(org.tribuo.protos.core.ModelDataProto.parser(), extensionRegistry);
            if (subBuilder != null) {
              subBuilder.mergeFrom(metadata_);
              metadata_ = subBuilder.buildPartial();
            }

            break;
          }
          case 18: {
            if (!((mutable_bitField0_ & 0x00000001) != 0)) {
              centroidVectors_ = new java.util.ArrayList<org.tribuo.math.protos.TensorProto>();
              mutable_bitField0_ |= 0x00000001;
            }
            centroidVectors_.add(
                input.readMessage(org.tribuo.math.protos.TensorProto.parser(), extensionRegistry));
            break;
          }
          case 26: {
            org.tribuo.math.protos.DistanceProto.Builder subBuilder = null;
            if (distance_ != null) {
              subBuilder = distance_.toBuilder();
            }
            distance_ = input.readMessage(org.tribuo.math.protos.DistanceProto.parser(), extensionRegistry);
            if (subBuilder != null) {
              subBuilder.mergeFrom(distance_);
              distance_ = subBuilder.buildPartial();
            }

            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)) {
        centroidVectors_ = java.util.Collections.unmodifiableList(centroidVectors_);
      }
      this.unknownFields = unknownFields.build();
      makeExtensionsImmutable();
    }
  }
  public static final com.google.protobuf.Descriptors.Descriptor
      getDescriptor() {
    return org.tribuo.clustering.kmeans.protos.TribuoClusteringKmeans.internal_static_tribuo_clustering_kmeans_KMeansModelProto_descriptor;
  }

  @java.lang.Override
  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
      internalGetFieldAccessorTable() {
    return org.tribuo.clustering.kmeans.protos.TribuoClusteringKmeans.internal_static_tribuo_clustering_kmeans_KMeansModelProto_fieldAccessorTable
        .ensureFieldAccessorsInitialized(
            org.tribuo.clustering.kmeans.protos.KMeansModelProto.class, org.tribuo.clustering.kmeans.protos.KMeansModelProto.Builder.class);
  }

  public static final int METADATA_FIELD_NUMBER = 1;
  private org.tribuo.protos.core.ModelDataProto metadata_;
  /**
   * <code>.tribuo.core.ModelDataProto metadata = 1;</code>
   * @return Whether the metadata field is set.
   */
  @java.lang.Override
  public boolean hasMetadata() {
    return metadata_ != null;
  }
  /**
   * <code>.tribuo.core.ModelDataProto metadata = 1;</code>
   * @return The metadata.
   */
  @java.lang.Override
  public org.tribuo.protos.core.ModelDataProto getMetadata() {
    return metadata_ == null ? org.tribuo.protos.core.ModelDataProto.getDefaultInstance() : metadata_;
  }
  /**
   * <code>.tribuo.core.ModelDataProto metadata = 1;</code>
   */
  @java.lang.Override
  public org.tribuo.protos.core.ModelDataProtoOrBuilder getMetadataOrBuilder() {
    return getMetadata();
  }

  public static final int CENTROID_VECTORS_FIELD_NUMBER = 2;
  private java.util.List<org.tribuo.math.protos.TensorProto> centroidVectors_;
  /**
   * <code>repeated .tribuo.math.TensorProto centroid_vectors = 2;</code>
   */
  @java.lang.Override
  public java.util.List<org.tribuo.math.protos.TensorProto> getCentroidVectorsList() {
    return centroidVectors_;
  }
  /**
   * <code>repeated .tribuo.math.TensorProto centroid_vectors = 2;</code>
   */
  @java.lang.Override
  public java.util.List<? extends org.tribuo.math.protos.TensorProtoOrBuilder> 
      getCentroidVectorsOrBuilderList() {
    return centroidVectors_;
  }
  /**
   * <code>repeated .tribuo.math.TensorProto centroid_vectors = 2;</code>
   */
  @java.lang.Override
  public int getCentroidVectorsCount() {
    return centroidVectors_.size();
  }
  /**
   * <code>repeated .tribuo.math.TensorProto centroid_vectors = 2;</code>
   */
  @java.lang.Override
  public org.tribuo.math.protos.TensorProto getCentroidVectors(int index) {
    return centroidVectors_.get(index);
  }
  /**
   * <code>repeated .tribuo.math.TensorProto centroid_vectors = 2;</code>
   */
  @java.lang.Override
  public org.tribuo.math.protos.TensorProtoOrBuilder getCentroidVectorsOrBuilder(
      int index) {
    return centroidVectors_.get(index);
  }

  public static final int DISTANCE_FIELD_NUMBER = 3;
  private org.tribuo.math.protos.DistanceProto distance_;
  /**
   * <code>.tribuo.math.DistanceProto distance = 3;</code>
   * @return Whether the distance field is set.
   */
  @java.lang.Override
  public boolean hasDistance() {
    return distance_ != null;
  }
  /**
   * <code>.tribuo.math.DistanceProto distance = 3;</code>
   * @return The distance.
   */
  @java.lang.Override
  public org.tribuo.math.protos.DistanceProto getDistance() {
    return distance_ == null ? org.tribuo.math.protos.DistanceProto.getDefaultInstance() : distance_;
  }
  /**
   * <code>.tribuo.math.DistanceProto distance = 3;</code>
   */
  @java.lang.Override
  public org.tribuo.math.protos.DistanceProtoOrBuilder getDistanceOrBuilder() {
    return getDistance();
  }

  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 (metadata_ != null) {
      output.writeMessage(1, getMetadata());
    }
    for (int i = 0; i < centroidVectors_.size(); i++) {
      output.writeMessage(2, centroidVectors_.get(i));
    }
    if (distance_ != null) {
      output.writeMessage(3, getDistance());
    }
    unknownFields.writeTo(output);
  }

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

    size = 0;
    if (metadata_ != null) {
      size += com.google.protobuf.CodedOutputStream
        .computeMessageSize(1, getMetadata());
    }
    for (int i = 0; i < centroidVectors_.size(); i++) {
      size += com.google.protobuf.CodedOutputStream
        .computeMessageSize(2, centroidVectors_.get(i));
    }
    if (distance_ != null) {
      size += com.google.protobuf.CodedOutputStream
        .computeMessageSize(3, getDistance());
    }
    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.tribuo.clustering.kmeans.protos.KMeansModelProto)) {
      return super.equals(obj);
    }
    org.tribuo.clustering.kmeans.protos.KMeansModelProto other = (org.tribuo.clustering.kmeans.protos.KMeansModelProto) obj;

    if (hasMetadata() != other.hasMetadata()) return false;
    if (hasMetadata()) {
      if (!getMetadata()
          .equals(other.getMetadata())) return false;
    }
    if (!getCentroidVectorsList()
        .equals(other.getCentroidVectorsList())) return false;
    if (hasDistance() != other.hasDistance()) return false;
    if (hasDistance()) {
      if (!getDistance()
          .equals(other.getDistance())) return false;
    }
    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();
    if (hasMetadata()) {
      hash = (37 * hash) + METADATA_FIELD_NUMBER;
      hash = (53 * hash) + getMetadata().hashCode();
    }
    if (getCentroidVectorsCount() > 0) {
      hash = (37 * hash) + CENTROID_VECTORS_FIELD_NUMBER;
      hash = (53 * hash) + getCentroidVectorsList().hashCode();
    }
    if (hasDistance()) {
      hash = (37 * hash) + DISTANCE_FIELD_NUMBER;
      hash = (53 * hash) + getDistance().hashCode();
    }
    hash = (29 * hash) + unknownFields.hashCode();
    memoizedHashCode = hash;
    return hash;
  }

  public static org.tribuo.clustering.kmeans.protos.KMeansModelProto parseFrom(
      java.nio.ByteBuffer data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }
  public static org.tribuo.clustering.kmeans.protos.KMeansModelProto parseFrom(
      java.nio.ByteBuffer data,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }
  public static org.tribuo.clustering.kmeans.protos.KMeansModelProto parseFrom(
      com.google.protobuf.ByteString data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }
  public static org.tribuo.clustering.kmeans.protos.KMeansModelProto parseFrom(
      com.google.protobuf.ByteString data,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }
  public static org.tribuo.clustering.kmeans.protos.KMeansModelProto parseFrom(byte[] data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }
  public static org.tribuo.clustering.kmeans.protos.KMeansModelProto parseFrom(
      byte[] data,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }
  public static org.tribuo.clustering.kmeans.protos.KMeansModelProto parseFrom(java.io.InputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseWithIOException(PARSER, input);
  }
  public static org.tribuo.clustering.kmeans.protos.KMeansModelProto 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.tribuo.clustering.kmeans.protos.KMeansModelProto parseDelimitedFrom(java.io.InputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseDelimitedWithIOException(PARSER, input);
  }
  public static org.tribuo.clustering.kmeans.protos.KMeansModelProto 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.tribuo.clustering.kmeans.protos.KMeansModelProto parseFrom(
      com.google.protobuf.CodedInputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseWithIOException(PARSER, input);
  }
  public static org.tribuo.clustering.kmeans.protos.KMeansModelProto 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.tribuo.clustering.kmeans.protos.KMeansModelProto 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>
   *KMeansModel proto
   * </pre>
   *
   * Protobuf type {@code tribuo.clustering.kmeans.KMeansModelProto}
   */
  public static final class Builder extends
      com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
      // @@protoc_insertion_point(builder_implements:tribuo.clustering.kmeans.KMeansModelProto)
      org.tribuo.clustering.kmeans.protos.KMeansModelProtoOrBuilder {
    public static final com.google.protobuf.Descriptors.Descriptor
        getDescriptor() {
      return org.tribuo.clustering.kmeans.protos.TribuoClusteringKmeans.internal_static_tribuo_clustering_kmeans_KMeansModelProto_descriptor;
    }

    @java.lang.Override
    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
        internalGetFieldAccessorTable() {
      return org.tribuo.clustering.kmeans.protos.TribuoClusteringKmeans.internal_static_tribuo_clustering_kmeans_KMeansModelProto_fieldAccessorTable
          .ensureFieldAccessorsInitialized(
              org.tribuo.clustering.kmeans.protos.KMeansModelProto.class, org.tribuo.clustering.kmeans.protos.KMeansModelProto.Builder.class);
    }

    // Construct using org.tribuo.clustering.kmeans.protos.KMeansModelProto.newBuilder()
    private Builder() {
      maybeForceBuilderInitialization();
    }

    private Builder(
        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
      super(parent);
      maybeForceBuilderInitialization();
    }
    private void maybeForceBuilderInitialization() {
      if (com.google.protobuf.GeneratedMessageV3
              .alwaysUseFieldBuilders) {
        getCentroidVectorsFieldBuilder();
      }
    }
    @java.lang.Override
    public Builder clear() {
      super.clear();
      if (metadataBuilder_ == null) {
        metadata_ = null;
      } else {
        metadata_ = null;
        metadataBuilder_ = null;
      }
      if (centroidVectorsBuilder_ == null) {
        centroidVectors_ = java.util.Collections.emptyList();
        bitField0_ = (bitField0_ & ~0x00000001);
      } else {
        centroidVectorsBuilder_.clear();
      }
      if (distanceBuilder_ == null) {
        distance_ = null;
      } else {
        distance_ = null;
        distanceBuilder_ = null;
      }
      return this;
    }

    @java.lang.Override
    public com.google.protobuf.Descriptors.Descriptor
        getDescriptorForType() {
      return org.tribuo.clustering.kmeans.protos.TribuoClusteringKmeans.internal_static_tribuo_clustering_kmeans_KMeansModelProto_descriptor;
    }

    @java.lang.Override
    public org.tribuo.clustering.kmeans.protos.KMeansModelProto getDefaultInstanceForType() {
      return org.tribuo.clustering.kmeans.protos.KMeansModelProto.getDefaultInstance();
    }

    @java.lang.Override
    public org.tribuo.clustering.kmeans.protos.KMeansModelProto build() {
      org.tribuo.clustering.kmeans.protos.KMeansModelProto result = buildPartial();
      if (!result.isInitialized()) {
        throw newUninitializedMessageException(result);
      }
      return result;
    }

    @java.lang.Override
    public org.tribuo.clustering.kmeans.protos.KMeansModelProto buildPartial() {
      org.tribuo.clustering.kmeans.protos.KMeansModelProto result = new org.tribuo.clustering.kmeans.protos.KMeansModelProto(this);
      int from_bitField0_ = bitField0_;
      if (metadataBuilder_ == null) {
        result.metadata_ = metadata_;
      } else {
        result.metadata_ = metadataBuilder_.build();
      }
      if (centroidVectorsBuilder_ == null) {
        if (((bitField0_ & 0x00000001) != 0)) {
          centroidVectors_ = java.util.Collections.unmodifiableList(centroidVectors_);
          bitField0_ = (bitField0_ & ~0x00000001);
        }
        result.centroidVectors_ = centroidVectors_;
      } else {
        result.centroidVectors_ = centroidVectorsBuilder_.build();
      }
      if (distanceBuilder_ == null) {
        result.distance_ = distance_;
      } else {
        result.distance_ = distanceBuilder_.build();
      }
      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.tribuo.clustering.kmeans.protos.KMeansModelProto) {
        return mergeFrom((org.tribuo.clustering.kmeans.protos.KMeansModelProto)other);
      } else {
        super.mergeFrom(other);
        return this;
      }
    }

    public Builder mergeFrom(org.tribuo.clustering.kmeans.protos.KMeansModelProto other) {
      if (other == org.tribuo.clustering.kmeans.protos.KMeansModelProto.getDefaultInstance()) return this;
      if (other.hasMetadata()) {
        mergeMetadata(other.getMetadata());
      }
      if (centroidVectorsBuilder_ == null) {
        if (!other.centroidVectors_.isEmpty()) {
          if (centroidVectors_.isEmpty()) {
            centroidVectors_ = other.centroidVectors_;
            bitField0_ = (bitField0_ & ~0x00000001);
          } else {
            ensureCentroidVectorsIsMutable();
            centroidVectors_.addAll(other.centroidVectors_);
          }
          onChanged();
        }
      } else {
        if (!other.centroidVectors_.isEmpty()) {
          if (centroidVectorsBuilder_.isEmpty()) {
            centroidVectorsBuilder_.dispose();
            centroidVectorsBuilder_ = null;
            centroidVectors_ = other.centroidVectors_;
            bitField0_ = (bitField0_ & ~0x00000001);
            centroidVectorsBuilder_ = 
              com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
                 getCentroidVectorsFieldBuilder() : null;
          } else {
            centroidVectorsBuilder_.addAllMessages(other.centroidVectors_);
          }
        }
      }
      if (other.hasDistance()) {
        mergeDistance(other.getDistance());
      }
      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.tribuo.clustering.kmeans.protos.KMeansModelProto parsedMessage = null;
      try {
        parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
      } catch (com.google.protobuf.InvalidProtocolBufferException e) {
        parsedMessage = (org.tribuo.clustering.kmeans.protos.KMeansModelProto) e.getUnfinishedMessage();
        throw e.unwrapIOException();
      } finally {
        if (parsedMessage != null) {
          mergeFrom(parsedMessage);
        }
      }
      return this;
    }
    private int bitField0_;

    private org.tribuo.protos.core.ModelDataProto metadata_;
    private com.google.protobuf.SingleFieldBuilderV3<
        org.tribuo.protos.core.ModelDataProto, org.tribuo.protos.core.ModelDataProto.Builder, org.tribuo.protos.core.ModelDataProtoOrBuilder> metadataBuilder_;
    /**
     * <code>.tribuo.core.ModelDataProto metadata = 1;</code>
     * @return Whether the metadata field is set.
     */
    public boolean hasMetadata() {
      return metadataBuilder_ != null || metadata_ != null;
    }
    /**
     * <code>.tribuo.core.ModelDataProto metadata = 1;</code>
     * @return The metadata.
     */
    public org.tribuo.protos.core.ModelDataProto getMetadata() {
      if (metadataBuilder_ == null) {
        return metadata_ == null ? org.tribuo.protos.core.ModelDataProto.getDefaultInstance() : metadata_;
      } else {
        return metadataBuilder_.getMessage();
      }
    }
    /**
     * <code>.tribuo.core.ModelDataProto metadata = 1;</code>
     */
    public Builder setMetadata(org.tribuo.protos.core.ModelDataProto value) {
      if (metadataBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        metadata_ = value;
        onChanged();
      } else {
        metadataBuilder_.setMessage(value);
      }

      return this;
    }
    /**
     * <code>.tribuo.core.ModelDataProto metadata = 1;</code>
     */
    public Builder setMetadata(
        org.tribuo.protos.core.ModelDataProto.Builder builderForValue) {
      if (metadataBuilder_ == null) {
        metadata_ = builderForValue.build();
        onChanged();
      } else {
        metadataBuilder_.setMessage(builderForValue.build());
      }

      return this;
    }
    /**
     * <code>.tribuo.core.ModelDataProto metadata = 1;</code>
     */
    public Builder mergeMetadata(org.tribuo.protos.core.ModelDataProto value) {
      if (metadataBuilder_ == null) {
        if (metadata_ != null) {
          metadata_ =
            org.tribuo.protos.core.ModelDataProto.newBuilder(metadata_).mergeFrom(value).buildPartial();
        } else {
          metadata_ = value;
        }
        onChanged();
      } else {
        metadataBuilder_.mergeFrom(value);
      }

      return this;
    }
    /**
     * <code>.tribuo.core.ModelDataProto metadata = 1;</code>
     */
    public Builder clearMetadata() {
      if (metadataBuilder_ == null) {
        metadata_ = null;
        onChanged();
      } else {
        metadata_ = null;
        metadataBuilder_ = null;
      }

      return this;
    }
    /**
     * <code>.tribuo.core.ModelDataProto metadata = 1;</code>
     */
    public org.tribuo.protos.core.ModelDataProto.Builder getMetadataBuilder() {
      
      onChanged();
      return getMetadataFieldBuilder().getBuilder();
    }
    /**
     * <code>.tribuo.core.ModelDataProto metadata = 1;</code>
     */
    public org.tribuo.protos.core.ModelDataProtoOrBuilder getMetadataOrBuilder() {
      if (metadataBuilder_ != null) {
        return metadataBuilder_.getMessageOrBuilder();
      } else {
        return metadata_ == null ?
            org.tribuo.protos.core.ModelDataProto.getDefaultInstance() : metadata_;
      }
    }
    /**
     * <code>.tribuo.core.ModelDataProto metadata = 1;</code>
     */
    private com.google.protobuf.SingleFieldBuilderV3<
        org.tribuo.protos.core.ModelDataProto, org.tribuo.protos.core.ModelDataProto.Builder, org.tribuo.protos.core.ModelDataProtoOrBuilder> 
        getMetadataFieldBuilder() {
      if (metadataBuilder_ == null) {
        metadataBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
            org.tribuo.protos.core.ModelDataProto, org.tribuo.protos.core.ModelDataProto.Builder, org.tribuo.protos.core.ModelDataProtoOrBuilder>(
                getMetadata(),
                getParentForChildren(),
                isClean());
        metadata_ = null;
      }
      return metadataBuilder_;
    }

    private java.util.List<org.tribuo.math.protos.TensorProto> centroidVectors_ =
      java.util.Collections.emptyList();
    private void ensureCentroidVectorsIsMutable() {
      if (!((bitField0_ & 0x00000001) != 0)) {
        centroidVectors_ = new java.util.ArrayList<org.tribuo.math.protos.TensorProto>(centroidVectors_);
        bitField0_ |= 0x00000001;
       }
    }

    private com.google.protobuf.RepeatedFieldBuilderV3<
        org.tribuo.math.protos.TensorProto, org.tribuo.math.protos.TensorProto.Builder, org.tribuo.math.protos.TensorProtoOrBuilder> centroidVectorsBuilder_;

    /**
     * <code>repeated .tribuo.math.TensorProto centroid_vectors = 2;</code>
     */
    public java.util.List<org.tribuo.math.protos.TensorProto> getCentroidVectorsList() {
      if (centroidVectorsBuilder_ == null) {
        return java.util.Collections.unmodifiableList(centroidVectors_);
      } else {
        return centroidVectorsBuilder_.getMessageList();
      }
    }
    /**
     * <code>repeated .tribuo.math.TensorProto centroid_vectors = 2;</code>
     */
    public int getCentroidVectorsCount() {
      if (centroidVectorsBuilder_ == null) {
        return centroidVectors_.size();
      } else {
        return centroidVectorsBuilder_.getCount();
      }
    }
    /**
     * <code>repeated .tribuo.math.TensorProto centroid_vectors = 2;</code>
     */
    public org.tribuo.math.protos.TensorProto getCentroidVectors(int index) {
      if (centroidVectorsBuilder_ == null) {
        return centroidVectors_.get(index);
      } else {
        return centroidVectorsBuilder_.getMessage(index);
      }
    }
    /**
     * <code>repeated .tribuo.math.TensorProto centroid_vectors = 2;</code>
     */
    public Builder setCentroidVectors(
        int index, org.tribuo.math.protos.TensorProto value) {
      if (centroidVectorsBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureCentroidVectorsIsMutable();
        centroidVectors_.set(index, value);
        onChanged();
      } else {
        centroidVectorsBuilder_.setMessage(index, value);
      }
      return this;
    }
    /**
     * <code>repeated .tribuo.math.TensorProto centroid_vectors = 2;</code>
     */
    public Builder setCentroidVectors(
        int index, org.tribuo.math.protos.TensorProto.Builder builderForValue) {
      if (centroidVectorsBuilder_ == null) {
        ensureCentroidVectorsIsMutable();
        centroidVectors_.set(index, builderForValue.build());
        onChanged();
      } else {
        centroidVectorsBuilder_.setMessage(index, builderForValue.build());
      }
      return this;
    }
    /**
     * <code>repeated .tribuo.math.TensorProto centroid_vectors = 2;</code>
     */
    public Builder addCentroidVectors(org.tribuo.math.protos.TensorProto value) {
      if (centroidVectorsBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureCentroidVectorsIsMutable();
        centroidVectors_.add(value);
        onChanged();
      } else {
        centroidVectorsBuilder_.addMessage(value);
      }
      return this;
    }
    /**
     * <code>repeated .tribuo.math.TensorProto centroid_vectors = 2;</code>
     */
    public Builder addCentroidVectors(
        int index, org.tribuo.math.protos.TensorProto value) {
      if (centroidVectorsBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureCentroidVectorsIsMutable();
        centroidVectors_.add(index, value);
        onChanged();
      } else {
        centroidVectorsBuilder_.addMessage(index, value);
      }
      return this;
    }
    /**
     * <code>repeated .tribuo.math.TensorProto centroid_vectors = 2;</code>
     */
    public Builder addCentroidVectors(
        org.tribuo.math.protos.TensorProto.Builder builderForValue) {
      if (centroidVectorsBuilder_ == null) {
        ensureCentroidVectorsIsMutable();
        centroidVectors_.add(builderForValue.build());
        onChanged();
      } else {
        centroidVectorsBuilder_.addMessage(builderForValue.build());
      }
      return this;
    }
    /**
     * <code>repeated .tribuo.math.TensorProto centroid_vectors = 2;</code>
     */
    public Builder addCentroidVectors(
        int index, org.tribuo.math.protos.TensorProto.Builder builderForValue) {
      if (centroidVectorsBuilder_ == null) {
        ensureCentroidVectorsIsMutable();
        centroidVectors_.add(index, builderForValue.build());
        onChanged();
      } else {
        centroidVectorsBuilder_.addMessage(index, builderForValue.build());
      }
      return this;
    }
    /**
     * <code>repeated .tribuo.math.TensorProto centroid_vectors = 2;</code>
     */
    public Builder addAllCentroidVectors(
        java.lang.Iterable<? extends org.tribuo.math.protos.TensorProto> values) {
      if (centroidVectorsBuilder_ == null) {
        ensureCentroidVectorsIsMutable();
        com.google.protobuf.AbstractMessageLite.Builder.addAll(
            values, centroidVectors_);
        onChanged();
      } else {
        centroidVectorsBuilder_.addAllMessages(values);
      }
      return this;
    }
    /**
     * <code>repeated .tribuo.math.TensorProto centroid_vectors = 2;</code>
     */
    public Builder clearCentroidVectors() {
      if (centroidVectorsBuilder_ == null) {
        centroidVectors_ = java.util.Collections.emptyList();
        bitField0_ = (bitField0_ & ~0x00000001);
        onChanged();
      } else {
        centroidVectorsBuilder_.clear();
      }
      return this;
    }
    /**
     * <code>repeated .tribuo.math.TensorProto centroid_vectors = 2;</code>
     */
    public Builder removeCentroidVectors(int index) {
      if (centroidVectorsBuilder_ == null) {
        ensureCentroidVectorsIsMutable();
        centroidVectors_.remove(index);
        onChanged();
      } else {
        centroidVectorsBuilder_.remove(index);
      }
      return this;
    }
    /**
     * <code>repeated .tribuo.math.TensorProto centroid_vectors = 2;</code>
     */
    public org.tribuo.math.protos.TensorProto.Builder getCentroidVectorsBuilder(
        int index) {
      return getCentroidVectorsFieldBuilder().getBuilder(index);
    }
    /**
     * <code>repeated .tribuo.math.TensorProto centroid_vectors = 2;</code>
     */
    public org.tribuo.math.protos.TensorProtoOrBuilder getCentroidVectorsOrBuilder(
        int index) {
      if (centroidVectorsBuilder_ == null) {
        return centroidVectors_.get(index);  } else {
        return centroidVectorsBuilder_.getMessageOrBuilder(index);
      }
    }
    /**
     * <code>repeated .tribuo.math.TensorProto centroid_vectors = 2;</code>
     */
    public java.util.List<? extends org.tribuo.math.protos.TensorProtoOrBuilder> 
         getCentroidVectorsOrBuilderList() {
      if (centroidVectorsBuilder_ != null) {
        return centroidVectorsBuilder_.getMessageOrBuilderList();
      } else {
        return java.util.Collections.unmodifiableList(centroidVectors_);
      }
    }
    /**
     * <code>repeated .tribuo.math.TensorProto centroid_vectors = 2;</code>
     */
    public org.tribuo.math.protos.TensorProto.Builder addCentroidVectorsBuilder() {
      return getCentroidVectorsFieldBuilder().addBuilder(
          org.tribuo.math.protos.TensorProto.getDefaultInstance());
    }
    /**
     * <code>repeated .tribuo.math.TensorProto centroid_vectors = 2;</code>
     */
    public org.tribuo.math.protos.TensorProto.Builder addCentroidVectorsBuilder(
        int index) {
      return getCentroidVectorsFieldBuilder().addBuilder(
          index, org.tribuo.math.protos.TensorProto.getDefaultInstance());
    }
    /**
     * <code>repeated .tribuo.math.TensorProto centroid_vectors = 2;</code>
     */
    public java.util.List<org.tribuo.math.protos.TensorProto.Builder> 
         getCentroidVectorsBuilderList() {
      return getCentroidVectorsFieldBuilder().getBuilderList();
    }
    private com.google.protobuf.RepeatedFieldBuilderV3<
        org.tribuo.math.protos.TensorProto, org.tribuo.math.protos.TensorProto.Builder, org.tribuo.math.protos.TensorProtoOrBuilder> 
        getCentroidVectorsFieldBuilder() {
      if (centroidVectorsBuilder_ == null) {
        centroidVectorsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
            org.tribuo.math.protos.TensorProto, org.tribuo.math.protos.TensorProto.Builder, org.tribuo.math.protos.TensorProtoOrBuilder>(
                centroidVectors_,
                ((bitField0_ & 0x00000001) != 0),
                getParentForChildren(),
                isClean());
        centroidVectors_ = null;
      }
      return centroidVectorsBuilder_;
    }

    private org.tribuo.math.protos.DistanceProto distance_;
    private com.google.protobuf.SingleFieldBuilderV3<
        org.tribuo.math.protos.DistanceProto, org.tribuo.math.protos.DistanceProto.Builder, org.tribuo.math.protos.DistanceProtoOrBuilder> distanceBuilder_;
    /**
     * <code>.tribuo.math.DistanceProto distance = 3;</code>
     * @return Whether the distance field is set.
     */
    public boolean hasDistance() {
      return distanceBuilder_ != null || distance_ != null;
    }
    /**
     * <code>.tribuo.math.DistanceProto distance = 3;</code>
     * @return The distance.
     */
    public org.tribuo.math.protos.DistanceProto getDistance() {
      if (distanceBuilder_ == null) {
        return distance_ == null ? org.tribuo.math.protos.DistanceProto.getDefaultInstance() : distance_;
      } else {
        return distanceBuilder_.getMessage();
      }
    }
    /**
     * <code>.tribuo.math.DistanceProto distance = 3;</code>
     */
    public Builder setDistance(org.tribuo.math.protos.DistanceProto value) {
      if (distanceBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        distance_ = value;
        onChanged();
      } else {
        distanceBuilder_.setMessage(value);
      }

      return this;
    }
    /**
     * <code>.tribuo.math.DistanceProto distance = 3;</code>
     */
    public Builder setDistance(
        org.tribuo.math.protos.DistanceProto.Builder builderForValue) {
      if (distanceBuilder_ == null) {
        distance_ = builderForValue.build();
        onChanged();
      } else {
        distanceBuilder_.setMessage(builderForValue.build());
      }

      return this;
    }
    /**
     * <code>.tribuo.math.DistanceProto distance = 3;</code>
     */
    public Builder mergeDistance(org.tribuo.math.protos.DistanceProto value) {
      if (distanceBuilder_ == null) {
        if (distance_ != null) {
          distance_ =
            org.tribuo.math.protos.DistanceProto.newBuilder(distance_).mergeFrom(value).buildPartial();
        } else {
          distance_ = value;
        }
        onChanged();
      } else {
        distanceBuilder_.mergeFrom(value);
      }

      return this;
    }
    /**
     * <code>.tribuo.math.DistanceProto distance = 3;</code>
     */
    public Builder clearDistance() {
      if (distanceBuilder_ == null) {
        distance_ = null;
        onChanged();
      } else {
        distance_ = null;
        distanceBuilder_ = null;
      }

      return this;
    }
    /**
     * <code>.tribuo.math.DistanceProto distance = 3;</code>
     */
    public org.tribuo.math.protos.DistanceProto.Builder getDistanceBuilder() {
      
      onChanged();
      return getDistanceFieldBuilder().getBuilder();
    }
    /**
     * <code>.tribuo.math.DistanceProto distance = 3;</code>
     */
    public org.tribuo.math.protos.DistanceProtoOrBuilder getDistanceOrBuilder() {
      if (distanceBuilder_ != null) {
        return distanceBuilder_.getMessageOrBuilder();
      } else {
        return distance_ == null ?
            org.tribuo.math.protos.DistanceProto.getDefaultInstance() : distance_;
      }
    }
    /**
     * <code>.tribuo.math.DistanceProto distance = 3;</code>
     */
    private com.google.protobuf.SingleFieldBuilderV3<
        org.tribuo.math.protos.DistanceProto, org.tribuo.math.protos.DistanceProto.Builder, org.tribuo.math.protos.DistanceProtoOrBuilder> 
        getDistanceFieldBuilder() {
      if (distanceBuilder_ == null) {
        distanceBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
            org.tribuo.math.protos.DistanceProto, org.tribuo.math.protos.DistanceProto.Builder, org.tribuo.math.protos.DistanceProtoOrBuilder>(
                getDistance(),
                getParentForChildren(),
                isClean());
        distance_ = null;
      }
      return distanceBuilder_;
    }
    @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:tribuo.clustering.kmeans.KMeansModelProto)
  }

  // @@protoc_insertion_point(class_scope:tribuo.clustering.kmeans.KMeansModelProto)
  private static final org.tribuo.clustering.kmeans.protos.KMeansModelProto DEFAULT_INSTANCE;
  static {
    DEFAULT_INSTANCE = new org.tribuo.clustering.kmeans.protos.KMeansModelProto();
  }

  public static org.tribuo.clustering.kmeans.protos.KMeansModelProto getDefaultInstance() {
    return DEFAULT_INSTANCE;
  }

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

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

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

  @java.lang.Override
  public org.tribuo.clustering.kmeans.protos.KMeansModelProto getDefaultInstanceForType() {
    return DEFAULT_INSTANCE;
  }

}

