/*
 * Copyright 2020 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: google/cloud/recommendationengine/v1beta1/user_event.proto

package com.google.cloud.recommendationengine.v1beta1;

/**
 *
 *
 * <pre>
 * A transaction represents the entire purchase transaction.
 * </pre>
 *
 * Protobuf type {@code google.cloud.recommendationengine.v1beta1.PurchaseTransaction}
 */
public final class PurchaseTransaction extends com.google.protobuf.GeneratedMessageV3
    implements
    // @@protoc_insertion_point(message_implements:google.cloud.recommendationengine.v1beta1.PurchaseTransaction)
    PurchaseTransactionOrBuilder {
  private static final long serialVersionUID = 0L;
  // Use PurchaseTransaction.newBuilder() to construct.
  private PurchaseTransaction(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
    super(builder);
  }

  private PurchaseTransaction() {
    id_ = "";
    currencyCode_ = "";
  }

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

  @java.lang.Override
  public final com.google.protobuf.UnknownFieldSet getUnknownFields() {
    return this.unknownFields;
  }

  public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
    return com.google.cloud.recommendationengine.v1beta1.UserEventOuterClass
        .internal_static_google_cloud_recommendationengine_v1beta1_PurchaseTransaction_descriptor;
  }

  @SuppressWarnings({"rawtypes"})
  @java.lang.Override
  protected com.google.protobuf.MapField internalGetMapField(int number) {
    switch (number) {
      case 3:
        return internalGetTaxes();
      case 4:
        return internalGetCosts();
      default:
        throw new RuntimeException("Invalid map field number: " + number);
    }
  }

  @java.lang.Override
  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
      internalGetFieldAccessorTable() {
    return com.google.cloud.recommendationengine.v1beta1.UserEventOuterClass
        .internal_static_google_cloud_recommendationengine_v1beta1_PurchaseTransaction_fieldAccessorTable
        .ensureFieldAccessorsInitialized(
            com.google.cloud.recommendationengine.v1beta1.PurchaseTransaction.class,
            com.google.cloud.recommendationengine.v1beta1.PurchaseTransaction.Builder.class);
  }

  public static final int ID_FIELD_NUMBER = 1;

  @SuppressWarnings("serial")
  private volatile java.lang.Object id_ = "";
  /**
   *
   *
   * <pre>
   * Optional. The transaction ID with a length limit of 128 bytes.
   * </pre>
   *
   * <code>string id = 1 [(.google.api.field_behavior) = OPTIONAL];</code>
   *
   * @return The id.
   */
  @java.lang.Override
  public java.lang.String getId() {
    java.lang.Object ref = id_;
    if (ref instanceof java.lang.String) {
      return (java.lang.String) ref;
    } else {
      com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
      java.lang.String s = bs.toStringUtf8();
      id_ = s;
      return s;
    }
  }
  /**
   *
   *
   * <pre>
   * Optional. The transaction ID with a length limit of 128 bytes.
   * </pre>
   *
   * <code>string id = 1 [(.google.api.field_behavior) = OPTIONAL];</code>
   *
   * @return The bytes for id.
   */
  @java.lang.Override
  public com.google.protobuf.ByteString getIdBytes() {
    java.lang.Object ref = id_;
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b =
          com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
      id_ = b;
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }

  public static final int REVENUE_FIELD_NUMBER = 2;
  private float revenue_ = 0F;
  /**
   *
   *
   * <pre>
   * Required. Total revenue or grand total associated with the transaction.
   * This value include shipping, tax, or other adjustments to total revenue
   * that you want to include as part of your revenue calculations. This field
   * is not required if the event type is `refund`.
   * </pre>
   *
   * <code>float revenue = 2 [(.google.api.field_behavior) = REQUIRED];</code>
   *
   * @return The revenue.
   */
  @java.lang.Override
  public float getRevenue() {
    return revenue_;
  }

  public static final int TAXES_FIELD_NUMBER = 3;

  private static final class TaxesDefaultEntryHolder {
    static final com.google.protobuf.MapEntry<java.lang.String, java.lang.Float> defaultEntry =
        com.google.protobuf.MapEntry.<java.lang.String, java.lang.Float>newDefaultInstance(
            com.google.cloud.recommendationengine.v1beta1.UserEventOuterClass
                .internal_static_google_cloud_recommendationengine_v1beta1_PurchaseTransaction_TaxesEntry_descriptor,
            com.google.protobuf.WireFormat.FieldType.STRING,
            "",
            com.google.protobuf.WireFormat.FieldType.FLOAT,
            0F);
  }

  @SuppressWarnings("serial")
  private com.google.protobuf.MapField<java.lang.String, java.lang.Float> taxes_;

  private com.google.protobuf.MapField<java.lang.String, java.lang.Float> internalGetTaxes() {
    if (taxes_ == null) {
      return com.google.protobuf.MapField.emptyMapField(TaxesDefaultEntryHolder.defaultEntry);
    }
    return taxes_;
  }

  public int getTaxesCount() {
    return internalGetTaxes().getMap().size();
  }
  /**
   *
   *
   * <pre>
   * Optional. All the taxes associated with the transaction.
   * </pre>
   *
   * <code>map&lt;string, float&gt; taxes = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
   */
  @java.lang.Override
  public boolean containsTaxes(java.lang.String key) {
    if (key == null) {
      throw new NullPointerException("map key");
    }
    return internalGetTaxes().getMap().containsKey(key);
  }
  /** Use {@link #getTaxesMap()} instead. */
  @java.lang.Override
  @java.lang.Deprecated
  public java.util.Map<java.lang.String, java.lang.Float> getTaxes() {
    return getTaxesMap();
  }
  /**
   *
   *
   * <pre>
   * Optional. All the taxes associated with the transaction.
   * </pre>
   *
   * <code>map&lt;string, float&gt; taxes = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
   */
  @java.lang.Override
  public java.util.Map<java.lang.String, java.lang.Float> getTaxesMap() {
    return internalGetTaxes().getMap();
  }
  /**
   *
   *
   * <pre>
   * Optional. All the taxes associated with the transaction.
   * </pre>
   *
   * <code>map&lt;string, float&gt; taxes = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
   */
  @java.lang.Override
  public float getTaxesOrDefault(java.lang.String key, float defaultValue) {
    if (key == null) {
      throw new NullPointerException("map key");
    }
    java.util.Map<java.lang.String, java.lang.Float> map = internalGetTaxes().getMap();
    return map.containsKey(key) ? map.get(key) : defaultValue;
  }
  /**
   *
   *
   * <pre>
   * Optional. All the taxes associated with the transaction.
   * </pre>
   *
   * <code>map&lt;string, float&gt; taxes = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
   */
  @java.lang.Override
  public float getTaxesOrThrow(java.lang.String key) {
    if (key == null) {
      throw new NullPointerException("map key");
    }
    java.util.Map<java.lang.String, java.lang.Float> map = internalGetTaxes().getMap();
    if (!map.containsKey(key)) {
      throw new java.lang.IllegalArgumentException();
    }
    return map.get(key);
  }

  public static final int COSTS_FIELD_NUMBER = 4;

  private static final class CostsDefaultEntryHolder {
    static final com.google.protobuf.MapEntry<java.lang.String, java.lang.Float> defaultEntry =
        com.google.protobuf.MapEntry.<java.lang.String, java.lang.Float>newDefaultInstance(
            com.google.cloud.recommendationengine.v1beta1.UserEventOuterClass
                .internal_static_google_cloud_recommendationengine_v1beta1_PurchaseTransaction_CostsEntry_descriptor,
            com.google.protobuf.WireFormat.FieldType.STRING,
            "",
            com.google.protobuf.WireFormat.FieldType.FLOAT,
            0F);
  }

  @SuppressWarnings("serial")
  private com.google.protobuf.MapField<java.lang.String, java.lang.Float> costs_;

  private com.google.protobuf.MapField<java.lang.String, java.lang.Float> internalGetCosts() {
    if (costs_ == null) {
      return com.google.protobuf.MapField.emptyMapField(CostsDefaultEntryHolder.defaultEntry);
    }
    return costs_;
  }

  public int getCostsCount() {
    return internalGetCosts().getMap().size();
  }
  /**
   *
   *
   * <pre>
   * Optional. All the costs associated with the product. These can be
   * manufacturing costs, shipping expenses not borne by the end user, or any
   * other costs.
   * Total product cost such that
   *   profit = revenue - (sum(taxes) + sum(costs))
   * If product_cost is not set, then
   *   profit = revenue - tax - shipping - sum(CatalogItem.costs).
   * If CatalogItem.cost is not specified for one of the items, CatalogItem.cost
   * based profit *cannot* be calculated for this Transaction.
   * </pre>
   *
   * <code>map&lt;string, float&gt; costs = 4 [(.google.api.field_behavior) = OPTIONAL];</code>
   */
  @java.lang.Override
  public boolean containsCosts(java.lang.String key) {
    if (key == null) {
      throw new NullPointerException("map key");
    }
    return internalGetCosts().getMap().containsKey(key);
  }
  /** Use {@link #getCostsMap()} instead. */
  @java.lang.Override
  @java.lang.Deprecated
  public java.util.Map<java.lang.String, java.lang.Float> getCosts() {
    return getCostsMap();
  }
  /**
   *
   *
   * <pre>
   * Optional. All the costs associated with the product. These can be
   * manufacturing costs, shipping expenses not borne by the end user, or any
   * other costs.
   * Total product cost such that
   *   profit = revenue - (sum(taxes) + sum(costs))
   * If product_cost is not set, then
   *   profit = revenue - tax - shipping - sum(CatalogItem.costs).
   * If CatalogItem.cost is not specified for one of the items, CatalogItem.cost
   * based profit *cannot* be calculated for this Transaction.
   * </pre>
   *
   * <code>map&lt;string, float&gt; costs = 4 [(.google.api.field_behavior) = OPTIONAL];</code>
   */
  @java.lang.Override
  public java.util.Map<java.lang.String, java.lang.Float> getCostsMap() {
    return internalGetCosts().getMap();
  }
  /**
   *
   *
   * <pre>
   * Optional. All the costs associated with the product. These can be
   * manufacturing costs, shipping expenses not borne by the end user, or any
   * other costs.
   * Total product cost such that
   *   profit = revenue - (sum(taxes) + sum(costs))
   * If product_cost is not set, then
   *   profit = revenue - tax - shipping - sum(CatalogItem.costs).
   * If CatalogItem.cost is not specified for one of the items, CatalogItem.cost
   * based profit *cannot* be calculated for this Transaction.
   * </pre>
   *
   * <code>map&lt;string, float&gt; costs = 4 [(.google.api.field_behavior) = OPTIONAL];</code>
   */
  @java.lang.Override
  public float getCostsOrDefault(java.lang.String key, float defaultValue) {
    if (key == null) {
      throw new NullPointerException("map key");
    }
    java.util.Map<java.lang.String, java.lang.Float> map = internalGetCosts().getMap();
    return map.containsKey(key) ? map.get(key) : defaultValue;
  }
  /**
   *
   *
   * <pre>
   * Optional. All the costs associated with the product. These can be
   * manufacturing costs, shipping expenses not borne by the end user, or any
   * other costs.
   * Total product cost such that
   *   profit = revenue - (sum(taxes) + sum(costs))
   * If product_cost is not set, then
   *   profit = revenue - tax - shipping - sum(CatalogItem.costs).
   * If CatalogItem.cost is not specified for one of the items, CatalogItem.cost
   * based profit *cannot* be calculated for this Transaction.
   * </pre>
   *
   * <code>map&lt;string, float&gt; costs = 4 [(.google.api.field_behavior) = OPTIONAL];</code>
   */
  @java.lang.Override
  public float getCostsOrThrow(java.lang.String key) {
    if (key == null) {
      throw new NullPointerException("map key");
    }
    java.util.Map<java.lang.String, java.lang.Float> map = internalGetCosts().getMap();
    if (!map.containsKey(key)) {
      throw new java.lang.IllegalArgumentException();
    }
    return map.get(key);
  }

  public static final int CURRENCY_CODE_FIELD_NUMBER = 6;

  @SuppressWarnings("serial")
  private volatile java.lang.Object currencyCode_ = "";
  /**
   *
   *
   * <pre>
   * Required. Currency code. Use three-character ISO-4217 code. This field
   * is not required if the event type is `refund`.
   * </pre>
   *
   * <code>string currency_code = 6 [(.google.api.field_behavior) = REQUIRED];</code>
   *
   * @return The currencyCode.
   */
  @java.lang.Override
  public java.lang.String getCurrencyCode() {
    java.lang.Object ref = currencyCode_;
    if (ref instanceof java.lang.String) {
      return (java.lang.String) ref;
    } else {
      com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
      java.lang.String s = bs.toStringUtf8();
      currencyCode_ = s;
      return s;
    }
  }
  /**
   *
   *
   * <pre>
   * Required. Currency code. Use three-character ISO-4217 code. This field
   * is not required if the event type is `refund`.
   * </pre>
   *
   * <code>string currency_code = 6 [(.google.api.field_behavior) = REQUIRED];</code>
   *
   * @return The bytes for currencyCode.
   */
  @java.lang.Override
  public com.google.protobuf.ByteString getCurrencyCodeBytes() {
    java.lang.Object ref = currencyCode_;
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b =
          com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
      currencyCode_ = b;
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }

  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 (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(id_)) {
      com.google.protobuf.GeneratedMessageV3.writeString(output, 1, id_);
    }
    if (java.lang.Float.floatToRawIntBits(revenue_) != 0) {
      output.writeFloat(2, revenue_);
    }
    com.google.protobuf.GeneratedMessageV3.serializeStringMapTo(
        output, internalGetTaxes(), TaxesDefaultEntryHolder.defaultEntry, 3);
    com.google.protobuf.GeneratedMessageV3.serializeStringMapTo(
        output, internalGetCosts(), CostsDefaultEntryHolder.defaultEntry, 4);
    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(currencyCode_)) {
      com.google.protobuf.GeneratedMessageV3.writeString(output, 6, currencyCode_);
    }
    getUnknownFields().writeTo(output);
  }

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

    size = 0;
    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(id_)) {
      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, id_);
    }
    if (java.lang.Float.floatToRawIntBits(revenue_) != 0) {
      size += com.google.protobuf.CodedOutputStream.computeFloatSize(2, revenue_);
    }
    for (java.util.Map.Entry<java.lang.String, java.lang.Float> entry :
        internalGetTaxes().getMap().entrySet()) {
      com.google.protobuf.MapEntry<java.lang.String, java.lang.Float> taxes__ =
          TaxesDefaultEntryHolder.defaultEntry
              .newBuilderForType()
              .setKey(entry.getKey())
              .setValue(entry.getValue())
              .build();
      size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, taxes__);
    }
    for (java.util.Map.Entry<java.lang.String, java.lang.Float> entry :
        internalGetCosts().getMap().entrySet()) {
      com.google.protobuf.MapEntry<java.lang.String, java.lang.Float> costs__ =
          CostsDefaultEntryHolder.defaultEntry
              .newBuilderForType()
              .setKey(entry.getKey())
              .setValue(entry.getValue())
              .build();
      size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, costs__);
    }
    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(currencyCode_)) {
      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, currencyCode_);
    }
    size += getUnknownFields().getSerializedSize();
    memoizedSize = size;
    return size;
  }

  @java.lang.Override
  public boolean equals(final java.lang.Object obj) {
    if (obj == this) {
      return true;
    }
    if (!(obj instanceof com.google.cloud.recommendationengine.v1beta1.PurchaseTransaction)) {
      return super.equals(obj);
    }
    com.google.cloud.recommendationengine.v1beta1.PurchaseTransaction other =
        (com.google.cloud.recommendationengine.v1beta1.PurchaseTransaction) obj;

    if (!getId().equals(other.getId())) return false;
    if (java.lang.Float.floatToIntBits(getRevenue())
        != java.lang.Float.floatToIntBits(other.getRevenue())) return false;
    if (!internalGetTaxes().equals(other.internalGetTaxes())) return false;
    if (!internalGetCosts().equals(other.internalGetCosts())) return false;
    if (!getCurrencyCode().equals(other.getCurrencyCode())) return false;
    if (!getUnknownFields().equals(other.getUnknownFields())) 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) + ID_FIELD_NUMBER;
    hash = (53 * hash) + getId().hashCode();
    hash = (37 * hash) + REVENUE_FIELD_NUMBER;
    hash = (53 * hash) + java.lang.Float.floatToIntBits(getRevenue());
    if (!internalGetTaxes().getMap().isEmpty()) {
      hash = (37 * hash) + TAXES_FIELD_NUMBER;
      hash = (53 * hash) + internalGetTaxes().hashCode();
    }
    if (!internalGetCosts().getMap().isEmpty()) {
      hash = (37 * hash) + COSTS_FIELD_NUMBER;
      hash = (53 * hash) + internalGetCosts().hashCode();
    }
    hash = (37 * hash) + CURRENCY_CODE_FIELD_NUMBER;
    hash = (53 * hash) + getCurrencyCode().hashCode();
    hash = (29 * hash) + getUnknownFields().hashCode();
    memoizedHashCode = hash;
    return hash;
  }

  public static com.google.cloud.recommendationengine.v1beta1.PurchaseTransaction parseFrom(
      java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

  public static com.google.cloud.recommendationengine.v1beta1.PurchaseTransaction parseFrom(
      java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }

  public static com.google.cloud.recommendationengine.v1beta1.PurchaseTransaction parseFrom(
      com.google.protobuf.ByteString data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

  public static com.google.cloud.recommendationengine.v1beta1.PurchaseTransaction parseFrom(
      com.google.protobuf.ByteString data,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }

  public static com.google.cloud.recommendationengine.v1beta1.PurchaseTransaction parseFrom(
      byte[] data) throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

  public static com.google.cloud.recommendationengine.v1beta1.PurchaseTransaction parseFrom(
      byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }

  public static com.google.cloud.recommendationengine.v1beta1.PurchaseTransaction parseFrom(
      java.io.InputStream input) throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
  }

  public static com.google.cloud.recommendationengine.v1beta1.PurchaseTransaction 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 com.google.cloud.recommendationengine.v1beta1.PurchaseTransaction
      parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
  }

  public static com.google.cloud.recommendationengine.v1beta1.PurchaseTransaction
      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 com.google.cloud.recommendationengine.v1beta1.PurchaseTransaction parseFrom(
      com.google.protobuf.CodedInputStream input) throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
  }

  public static com.google.cloud.recommendationengine.v1beta1.PurchaseTransaction 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(
      com.google.cloud.recommendationengine.v1beta1.PurchaseTransaction 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>
   * A transaction represents the entire purchase transaction.
   * </pre>
   *
   * Protobuf type {@code google.cloud.recommendationengine.v1beta1.PurchaseTransaction}
   */
  public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
      implements
      // @@protoc_insertion_point(builder_implements:google.cloud.recommendationengine.v1beta1.PurchaseTransaction)
      com.google.cloud.recommendationengine.v1beta1.PurchaseTransactionOrBuilder {
    public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
      return com.google.cloud.recommendationengine.v1beta1.UserEventOuterClass
          .internal_static_google_cloud_recommendationengine_v1beta1_PurchaseTransaction_descriptor;
    }

    @SuppressWarnings({"rawtypes"})
    protected com.google.protobuf.MapField internalGetMapField(int number) {
      switch (number) {
        case 3:
          return internalGetTaxes();
        case 4:
          return internalGetCosts();
        default:
          throw new RuntimeException("Invalid map field number: " + number);
      }
    }

    @SuppressWarnings({"rawtypes"})
    protected com.google.protobuf.MapField internalGetMutableMapField(int number) {
      switch (number) {
        case 3:
          return internalGetMutableTaxes();
        case 4:
          return internalGetMutableCosts();
        default:
          throw new RuntimeException("Invalid map field number: " + number);
      }
    }

    @java.lang.Override
    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
        internalGetFieldAccessorTable() {
      return com.google.cloud.recommendationengine.v1beta1.UserEventOuterClass
          .internal_static_google_cloud_recommendationengine_v1beta1_PurchaseTransaction_fieldAccessorTable
          .ensureFieldAccessorsInitialized(
              com.google.cloud.recommendationengine.v1beta1.PurchaseTransaction.class,
              com.google.cloud.recommendationengine.v1beta1.PurchaseTransaction.Builder.class);
    }

    // Construct using
    // com.google.cloud.recommendationengine.v1beta1.PurchaseTransaction.newBuilder()
    private Builder() {}

    private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
      super(parent);
    }

    @java.lang.Override
    public Builder clear() {
      super.clear();
      bitField0_ = 0;
      id_ = "";
      revenue_ = 0F;
      internalGetMutableTaxes().clear();
      internalGetMutableCosts().clear();
      currencyCode_ = "";
      return this;
    }

    @java.lang.Override
    public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
      return com.google.cloud.recommendationengine.v1beta1.UserEventOuterClass
          .internal_static_google_cloud_recommendationengine_v1beta1_PurchaseTransaction_descriptor;
    }

    @java.lang.Override
    public com.google.cloud.recommendationengine.v1beta1.PurchaseTransaction
        getDefaultInstanceForType() {
      return com.google.cloud.recommendationengine.v1beta1.PurchaseTransaction.getDefaultInstance();
    }

    @java.lang.Override
    public com.google.cloud.recommendationengine.v1beta1.PurchaseTransaction build() {
      com.google.cloud.recommendationengine.v1beta1.PurchaseTransaction result = buildPartial();
      if (!result.isInitialized()) {
        throw newUninitializedMessageException(result);
      }
      return result;
    }

    @java.lang.Override
    public com.google.cloud.recommendationengine.v1beta1.PurchaseTransaction buildPartial() {
      com.google.cloud.recommendationengine.v1beta1.PurchaseTransaction result =
          new com.google.cloud.recommendationengine.v1beta1.PurchaseTransaction(this);
      if (bitField0_ != 0) {
        buildPartial0(result);
      }
      onBuilt();
      return result;
    }

    private void buildPartial0(
        com.google.cloud.recommendationengine.v1beta1.PurchaseTransaction result) {
      int from_bitField0_ = bitField0_;
      if (((from_bitField0_ & 0x00000001) != 0)) {
        result.id_ = id_;
      }
      if (((from_bitField0_ & 0x00000002) != 0)) {
        result.revenue_ = revenue_;
      }
      if (((from_bitField0_ & 0x00000004) != 0)) {
        result.taxes_ = internalGetTaxes();
        result.taxes_.makeImmutable();
      }
      if (((from_bitField0_ & 0x00000008) != 0)) {
        result.costs_ = internalGetCosts();
        result.costs_.makeImmutable();
      }
      if (((from_bitField0_ & 0x00000010) != 0)) {
        result.currencyCode_ = currencyCode_;
      }
    }

    @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 com.google.cloud.recommendationengine.v1beta1.PurchaseTransaction) {
        return mergeFrom((com.google.cloud.recommendationengine.v1beta1.PurchaseTransaction) other);
      } else {
        super.mergeFrom(other);
        return this;
      }
    }

    public Builder mergeFrom(
        com.google.cloud.recommendationengine.v1beta1.PurchaseTransaction other) {
      if (other
          == com.google.cloud.recommendationengine.v1beta1.PurchaseTransaction.getDefaultInstance())
        return this;
      if (!other.getId().isEmpty()) {
        id_ = other.id_;
        bitField0_ |= 0x00000001;
        onChanged();
      }
      if (other.getRevenue() != 0F) {
        setRevenue(other.getRevenue());
      }
      internalGetMutableTaxes().mergeFrom(other.internalGetTaxes());
      bitField0_ |= 0x00000004;
      internalGetMutableCosts().mergeFrom(other.internalGetCosts());
      bitField0_ |= 0x00000008;
      if (!other.getCurrencyCode().isEmpty()) {
        currencyCode_ = other.currencyCode_;
        bitField0_ |= 0x00000010;
        onChanged();
      }
      this.mergeUnknownFields(other.getUnknownFields());
      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 {
      if (extensionRegistry == null) {
        throw new java.lang.NullPointerException();
      }
      try {
        boolean done = false;
        while (!done) {
          int tag = input.readTag();
          switch (tag) {
            case 0:
              done = true;
              break;
            case 10:
              {
                id_ = input.readStringRequireUtf8();
                bitField0_ |= 0x00000001;
                break;
              } // case 10
            case 21:
              {
                revenue_ = input.readFloat();
                bitField0_ |= 0x00000002;
                break;
              } // case 21
            case 26:
              {
                com.google.protobuf.MapEntry<java.lang.String, java.lang.Float> taxes__ =
                    input.readMessage(
                        TaxesDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry);
                internalGetMutableTaxes().getMutableMap().put(taxes__.getKey(), taxes__.getValue());
                bitField0_ |= 0x00000004;
                break;
              } // case 26
            case 34:
              {
                com.google.protobuf.MapEntry<java.lang.String, java.lang.Float> costs__ =
                    input.readMessage(
                        CostsDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry);
                internalGetMutableCosts().getMutableMap().put(costs__.getKey(), costs__.getValue());
                bitField0_ |= 0x00000008;
                break;
              } // case 34
            case 50:
              {
                currencyCode_ = input.readStringRequireUtf8();
                bitField0_ |= 0x00000010;
                break;
              } // case 50
            default:
              {
                if (!super.parseUnknownField(input, extensionRegistry, tag)) {
                  done = true; // was an endgroup tag
                }
                break;
              } // default:
          } // switch (tag)
        } // while (!done)
      } catch (com.google.protobuf.InvalidProtocolBufferException e) {
        throw e.unwrapIOException();
      } finally {
        onChanged();
      } // finally
      return this;
    }

    private int bitField0_;

    private java.lang.Object id_ = "";
    /**
     *
     *
     * <pre>
     * Optional. The transaction ID with a length limit of 128 bytes.
     * </pre>
     *
     * <code>string id = 1 [(.google.api.field_behavior) = OPTIONAL];</code>
     *
     * @return The id.
     */
    public java.lang.String getId() {
      java.lang.Object ref = id_;
      if (!(ref instanceof java.lang.String)) {
        com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
        java.lang.String s = bs.toStringUtf8();
        id_ = s;
        return s;
      } else {
        return (java.lang.String) ref;
      }
    }
    /**
     *
     *
     * <pre>
     * Optional. The transaction ID with a length limit of 128 bytes.
     * </pre>
     *
     * <code>string id = 1 [(.google.api.field_behavior) = OPTIONAL];</code>
     *
     * @return The bytes for id.
     */
    public com.google.protobuf.ByteString getIdBytes() {
      java.lang.Object ref = id_;
      if (ref instanceof String) {
        com.google.protobuf.ByteString b =
            com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
        id_ = b;
        return b;
      } else {
        return (com.google.protobuf.ByteString) ref;
      }
    }
    /**
     *
     *
     * <pre>
     * Optional. The transaction ID with a length limit of 128 bytes.
     * </pre>
     *
     * <code>string id = 1 [(.google.api.field_behavior) = OPTIONAL];</code>
     *
     * @param value The id to set.
     * @return This builder for chaining.
     */
    public Builder setId(java.lang.String value) {
      if (value == null) {
        throw new NullPointerException();
      }
      id_ = value;
      bitField0_ |= 0x00000001;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * Optional. The transaction ID with a length limit of 128 bytes.
     * </pre>
     *
     * <code>string id = 1 [(.google.api.field_behavior) = OPTIONAL];</code>
     *
     * @return This builder for chaining.
     */
    public Builder clearId() {
      id_ = getDefaultInstance().getId();
      bitField0_ = (bitField0_ & ~0x00000001);
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * Optional. The transaction ID with a length limit of 128 bytes.
     * </pre>
     *
     * <code>string id = 1 [(.google.api.field_behavior) = OPTIONAL];</code>
     *
     * @param value The bytes for id to set.
     * @return This builder for chaining.
     */
    public Builder setIdBytes(com.google.protobuf.ByteString value) {
      if (value == null) {
        throw new NullPointerException();
      }
      checkByteStringIsUtf8(value);
      id_ = value;
      bitField0_ |= 0x00000001;
      onChanged();
      return this;
    }

    private float revenue_;
    /**
     *
     *
     * <pre>
     * Required. Total revenue or grand total associated with the transaction.
     * This value include shipping, tax, or other adjustments to total revenue
     * that you want to include as part of your revenue calculations. This field
     * is not required if the event type is `refund`.
     * </pre>
     *
     * <code>float revenue = 2 [(.google.api.field_behavior) = REQUIRED];</code>
     *
     * @return The revenue.
     */
    @java.lang.Override
    public float getRevenue() {
      return revenue_;
    }
    /**
     *
     *
     * <pre>
     * Required. Total revenue or grand total associated with the transaction.
     * This value include shipping, tax, or other adjustments to total revenue
     * that you want to include as part of your revenue calculations. This field
     * is not required if the event type is `refund`.
     * </pre>
     *
     * <code>float revenue = 2 [(.google.api.field_behavior) = REQUIRED];</code>
     *
     * @param value The revenue to set.
     * @return This builder for chaining.
     */
    public Builder setRevenue(float value) {

      revenue_ = value;
      bitField0_ |= 0x00000002;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * Required. Total revenue or grand total associated with the transaction.
     * This value include shipping, tax, or other adjustments to total revenue
     * that you want to include as part of your revenue calculations. This field
     * is not required if the event type is `refund`.
     * </pre>
     *
     * <code>float revenue = 2 [(.google.api.field_behavior) = REQUIRED];</code>
     *
     * @return This builder for chaining.
     */
    public Builder clearRevenue() {
      bitField0_ = (bitField0_ & ~0x00000002);
      revenue_ = 0F;
      onChanged();
      return this;
    }

    private com.google.protobuf.MapField<java.lang.String, java.lang.Float> taxes_;

    private com.google.protobuf.MapField<java.lang.String, java.lang.Float> internalGetTaxes() {
      if (taxes_ == null) {
        return com.google.protobuf.MapField.emptyMapField(TaxesDefaultEntryHolder.defaultEntry);
      }
      return taxes_;
    }

    private com.google.protobuf.MapField<java.lang.String, java.lang.Float>
        internalGetMutableTaxes() {
      if (taxes_ == null) {
        taxes_ = com.google.protobuf.MapField.newMapField(TaxesDefaultEntryHolder.defaultEntry);
      }
      if (!taxes_.isMutable()) {
        taxes_ = taxes_.copy();
      }
      bitField0_ |= 0x00000004;
      onChanged();
      return taxes_;
    }

    public int getTaxesCount() {
      return internalGetTaxes().getMap().size();
    }
    /**
     *
     *
     * <pre>
     * Optional. All the taxes associated with the transaction.
     * </pre>
     *
     * <code>map&lt;string, float&gt; taxes = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
     */
    @java.lang.Override
    public boolean containsTaxes(java.lang.String key) {
      if (key == null) {
        throw new NullPointerException("map key");
      }
      return internalGetTaxes().getMap().containsKey(key);
    }
    /** Use {@link #getTaxesMap()} instead. */
    @java.lang.Override
    @java.lang.Deprecated
    public java.util.Map<java.lang.String, java.lang.Float> getTaxes() {
      return getTaxesMap();
    }
    /**
     *
     *
     * <pre>
     * Optional. All the taxes associated with the transaction.
     * </pre>
     *
     * <code>map&lt;string, float&gt; taxes = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
     */
    @java.lang.Override
    public java.util.Map<java.lang.String, java.lang.Float> getTaxesMap() {
      return internalGetTaxes().getMap();
    }
    /**
     *
     *
     * <pre>
     * Optional. All the taxes associated with the transaction.
     * </pre>
     *
     * <code>map&lt;string, float&gt; taxes = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
     */
    @java.lang.Override
    public float getTaxesOrDefault(java.lang.String key, float defaultValue) {
      if (key == null) {
        throw new NullPointerException("map key");
      }
      java.util.Map<java.lang.String, java.lang.Float> map = internalGetTaxes().getMap();
      return map.containsKey(key) ? map.get(key) : defaultValue;
    }
    /**
     *
     *
     * <pre>
     * Optional. All the taxes associated with the transaction.
     * </pre>
     *
     * <code>map&lt;string, float&gt; taxes = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
     */
    @java.lang.Override
    public float getTaxesOrThrow(java.lang.String key) {
      if (key == null) {
        throw new NullPointerException("map key");
      }
      java.util.Map<java.lang.String, java.lang.Float> map = internalGetTaxes().getMap();
      if (!map.containsKey(key)) {
        throw new java.lang.IllegalArgumentException();
      }
      return map.get(key);
    }

    public Builder clearTaxes() {
      bitField0_ = (bitField0_ & ~0x00000004);
      internalGetMutableTaxes().getMutableMap().clear();
      return this;
    }
    /**
     *
     *
     * <pre>
     * Optional. All the taxes associated with the transaction.
     * </pre>
     *
     * <code>map&lt;string, float&gt; taxes = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
     */
    public Builder removeTaxes(java.lang.String key) {
      if (key == null) {
        throw new NullPointerException("map key");
      }
      internalGetMutableTaxes().getMutableMap().remove(key);
      return this;
    }
    /** Use alternate mutation accessors instead. */
    @java.lang.Deprecated
    public java.util.Map<java.lang.String, java.lang.Float> getMutableTaxes() {
      bitField0_ |= 0x00000004;
      return internalGetMutableTaxes().getMutableMap();
    }
    /**
     *
     *
     * <pre>
     * Optional. All the taxes associated with the transaction.
     * </pre>
     *
     * <code>map&lt;string, float&gt; taxes = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
     */
    public Builder putTaxes(java.lang.String key, float value) {
      if (key == null) {
        throw new NullPointerException("map key");
      }

      internalGetMutableTaxes().getMutableMap().put(key, value);
      bitField0_ |= 0x00000004;
      return this;
    }
    /**
     *
     *
     * <pre>
     * Optional. All the taxes associated with the transaction.
     * </pre>
     *
     * <code>map&lt;string, float&gt; taxes = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
     */
    public Builder putAllTaxes(java.util.Map<java.lang.String, java.lang.Float> values) {
      internalGetMutableTaxes().getMutableMap().putAll(values);
      bitField0_ |= 0x00000004;
      return this;
    }

    private com.google.protobuf.MapField<java.lang.String, java.lang.Float> costs_;

    private com.google.protobuf.MapField<java.lang.String, java.lang.Float> internalGetCosts() {
      if (costs_ == null) {
        return com.google.protobuf.MapField.emptyMapField(CostsDefaultEntryHolder.defaultEntry);
      }
      return costs_;
    }

    private com.google.protobuf.MapField<java.lang.String, java.lang.Float>
        internalGetMutableCosts() {
      if (costs_ == null) {
        costs_ = com.google.protobuf.MapField.newMapField(CostsDefaultEntryHolder.defaultEntry);
      }
      if (!costs_.isMutable()) {
        costs_ = costs_.copy();
      }
      bitField0_ |= 0x00000008;
      onChanged();
      return costs_;
    }

    public int getCostsCount() {
      return internalGetCosts().getMap().size();
    }
    /**
     *
     *
     * <pre>
     * Optional. All the costs associated with the product. These can be
     * manufacturing costs, shipping expenses not borne by the end user, or any
     * other costs.
     * Total product cost such that
     *   profit = revenue - (sum(taxes) + sum(costs))
     * If product_cost is not set, then
     *   profit = revenue - tax - shipping - sum(CatalogItem.costs).
     * If CatalogItem.cost is not specified for one of the items, CatalogItem.cost
     * based profit *cannot* be calculated for this Transaction.
     * </pre>
     *
     * <code>map&lt;string, float&gt; costs = 4 [(.google.api.field_behavior) = OPTIONAL];</code>
     */
    @java.lang.Override
    public boolean containsCosts(java.lang.String key) {
      if (key == null) {
        throw new NullPointerException("map key");
      }
      return internalGetCosts().getMap().containsKey(key);
    }
    /** Use {@link #getCostsMap()} instead. */
    @java.lang.Override
    @java.lang.Deprecated
    public java.util.Map<java.lang.String, java.lang.Float> getCosts() {
      return getCostsMap();
    }
    /**
     *
     *
     * <pre>
     * Optional. All the costs associated with the product. These can be
     * manufacturing costs, shipping expenses not borne by the end user, or any
     * other costs.
     * Total product cost such that
     *   profit = revenue - (sum(taxes) + sum(costs))
     * If product_cost is not set, then
     *   profit = revenue - tax - shipping - sum(CatalogItem.costs).
     * If CatalogItem.cost is not specified for one of the items, CatalogItem.cost
     * based profit *cannot* be calculated for this Transaction.
     * </pre>
     *
     * <code>map&lt;string, float&gt; costs = 4 [(.google.api.field_behavior) = OPTIONAL];</code>
     */
    @java.lang.Override
    public java.util.Map<java.lang.String, java.lang.Float> getCostsMap() {
      return internalGetCosts().getMap();
    }
    /**
     *
     *
     * <pre>
     * Optional. All the costs associated with the product. These can be
     * manufacturing costs, shipping expenses not borne by the end user, or any
     * other costs.
     * Total product cost such that
     *   profit = revenue - (sum(taxes) + sum(costs))
     * If product_cost is not set, then
     *   profit = revenue - tax - shipping - sum(CatalogItem.costs).
     * If CatalogItem.cost is not specified for one of the items, CatalogItem.cost
     * based profit *cannot* be calculated for this Transaction.
     * </pre>
     *
     * <code>map&lt;string, float&gt; costs = 4 [(.google.api.field_behavior) = OPTIONAL];</code>
     */
    @java.lang.Override
    public float getCostsOrDefault(java.lang.String key, float defaultValue) {
      if (key == null) {
        throw new NullPointerException("map key");
      }
      java.util.Map<java.lang.String, java.lang.Float> map = internalGetCosts().getMap();
      return map.containsKey(key) ? map.get(key) : defaultValue;
    }
    /**
     *
     *
     * <pre>
     * Optional. All the costs associated with the product. These can be
     * manufacturing costs, shipping expenses not borne by the end user, or any
     * other costs.
     * Total product cost such that
     *   profit = revenue - (sum(taxes) + sum(costs))
     * If product_cost is not set, then
     *   profit = revenue - tax - shipping - sum(CatalogItem.costs).
     * If CatalogItem.cost is not specified for one of the items, CatalogItem.cost
     * based profit *cannot* be calculated for this Transaction.
     * </pre>
     *
     * <code>map&lt;string, float&gt; costs = 4 [(.google.api.field_behavior) = OPTIONAL];</code>
     */
    @java.lang.Override
    public float getCostsOrThrow(java.lang.String key) {
      if (key == null) {
        throw new NullPointerException("map key");
      }
      java.util.Map<java.lang.String, java.lang.Float> map = internalGetCosts().getMap();
      if (!map.containsKey(key)) {
        throw new java.lang.IllegalArgumentException();
      }
      return map.get(key);
    }

    public Builder clearCosts() {
      bitField0_ = (bitField0_ & ~0x00000008);
      internalGetMutableCosts().getMutableMap().clear();
      return this;
    }
    /**
     *
     *
     * <pre>
     * Optional. All the costs associated with the product. These can be
     * manufacturing costs, shipping expenses not borne by the end user, or any
     * other costs.
     * Total product cost such that
     *   profit = revenue - (sum(taxes) + sum(costs))
     * If product_cost is not set, then
     *   profit = revenue - tax - shipping - sum(CatalogItem.costs).
     * If CatalogItem.cost is not specified for one of the items, CatalogItem.cost
     * based profit *cannot* be calculated for this Transaction.
     * </pre>
     *
     * <code>map&lt;string, float&gt; costs = 4 [(.google.api.field_behavior) = OPTIONAL];</code>
     */
    public Builder removeCosts(java.lang.String key) {
      if (key == null) {
        throw new NullPointerException("map key");
      }
      internalGetMutableCosts().getMutableMap().remove(key);
      return this;
    }
    /** Use alternate mutation accessors instead. */
    @java.lang.Deprecated
    public java.util.Map<java.lang.String, java.lang.Float> getMutableCosts() {
      bitField0_ |= 0x00000008;
      return internalGetMutableCosts().getMutableMap();
    }
    /**
     *
     *
     * <pre>
     * Optional. All the costs associated with the product. These can be
     * manufacturing costs, shipping expenses not borne by the end user, or any
     * other costs.
     * Total product cost such that
     *   profit = revenue - (sum(taxes) + sum(costs))
     * If product_cost is not set, then
     *   profit = revenue - tax - shipping - sum(CatalogItem.costs).
     * If CatalogItem.cost is not specified for one of the items, CatalogItem.cost
     * based profit *cannot* be calculated for this Transaction.
     * </pre>
     *
     * <code>map&lt;string, float&gt; costs = 4 [(.google.api.field_behavior) = OPTIONAL];</code>
     */
    public Builder putCosts(java.lang.String key, float value) {
      if (key == null) {
        throw new NullPointerException("map key");
      }

      internalGetMutableCosts().getMutableMap().put(key, value);
      bitField0_ |= 0x00000008;
      return this;
    }
    /**
     *
     *
     * <pre>
     * Optional. All the costs associated with the product. These can be
     * manufacturing costs, shipping expenses not borne by the end user, or any
     * other costs.
     * Total product cost such that
     *   profit = revenue - (sum(taxes) + sum(costs))
     * If product_cost is not set, then
     *   profit = revenue - tax - shipping - sum(CatalogItem.costs).
     * If CatalogItem.cost is not specified for one of the items, CatalogItem.cost
     * based profit *cannot* be calculated for this Transaction.
     * </pre>
     *
     * <code>map&lt;string, float&gt; costs = 4 [(.google.api.field_behavior) = OPTIONAL];</code>
     */
    public Builder putAllCosts(java.util.Map<java.lang.String, java.lang.Float> values) {
      internalGetMutableCosts().getMutableMap().putAll(values);
      bitField0_ |= 0x00000008;
      return this;
    }

    private java.lang.Object currencyCode_ = "";
    /**
     *
     *
     * <pre>
     * Required. Currency code. Use three-character ISO-4217 code. This field
     * is not required if the event type is `refund`.
     * </pre>
     *
     * <code>string currency_code = 6 [(.google.api.field_behavior) = REQUIRED];</code>
     *
     * @return The currencyCode.
     */
    public java.lang.String getCurrencyCode() {
      java.lang.Object ref = currencyCode_;
      if (!(ref instanceof java.lang.String)) {
        com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
        java.lang.String s = bs.toStringUtf8();
        currencyCode_ = s;
        return s;
      } else {
        return (java.lang.String) ref;
      }
    }
    /**
     *
     *
     * <pre>
     * Required. Currency code. Use three-character ISO-4217 code. This field
     * is not required if the event type is `refund`.
     * </pre>
     *
     * <code>string currency_code = 6 [(.google.api.field_behavior) = REQUIRED];</code>
     *
     * @return The bytes for currencyCode.
     */
    public com.google.protobuf.ByteString getCurrencyCodeBytes() {
      java.lang.Object ref = currencyCode_;
      if (ref instanceof String) {
        com.google.protobuf.ByteString b =
            com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
        currencyCode_ = b;
        return b;
      } else {
        return (com.google.protobuf.ByteString) ref;
      }
    }
    /**
     *
     *
     * <pre>
     * Required. Currency code. Use three-character ISO-4217 code. This field
     * is not required if the event type is `refund`.
     * </pre>
     *
     * <code>string currency_code = 6 [(.google.api.field_behavior) = REQUIRED];</code>
     *
     * @param value The currencyCode to set.
     * @return This builder for chaining.
     */
    public Builder setCurrencyCode(java.lang.String value) {
      if (value == null) {
        throw new NullPointerException();
      }
      currencyCode_ = value;
      bitField0_ |= 0x00000010;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * Required. Currency code. Use three-character ISO-4217 code. This field
     * is not required if the event type is `refund`.
     * </pre>
     *
     * <code>string currency_code = 6 [(.google.api.field_behavior) = REQUIRED];</code>
     *
     * @return This builder for chaining.
     */
    public Builder clearCurrencyCode() {
      currencyCode_ = getDefaultInstance().getCurrencyCode();
      bitField0_ = (bitField0_ & ~0x00000010);
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * Required. Currency code. Use three-character ISO-4217 code. This field
     * is not required if the event type is `refund`.
     * </pre>
     *
     * <code>string currency_code = 6 [(.google.api.field_behavior) = REQUIRED];</code>
     *
     * @param value The bytes for currencyCode to set.
     * @return This builder for chaining.
     */
    public Builder setCurrencyCodeBytes(com.google.protobuf.ByteString value) {
      if (value == null) {
        throw new NullPointerException();
      }
      checkByteStringIsUtf8(value);
      currencyCode_ = value;
      bitField0_ |= 0x00000010;
      onChanged();
      return this;
    }

    @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:google.cloud.recommendationengine.v1beta1.PurchaseTransaction)
  }

  // @@protoc_insertion_point(class_scope:google.cloud.recommendationengine.v1beta1.PurchaseTransaction)
  private static final com.google.cloud.recommendationengine.v1beta1.PurchaseTransaction
      DEFAULT_INSTANCE;

  static {
    DEFAULT_INSTANCE = new com.google.cloud.recommendationengine.v1beta1.PurchaseTransaction();
  }

  public static com.google.cloud.recommendationengine.v1beta1.PurchaseTransaction
      getDefaultInstance() {
    return DEFAULT_INSTANCE;
  }

  private static final com.google.protobuf.Parser<PurchaseTransaction> PARSER =
      new com.google.protobuf.AbstractParser<PurchaseTransaction>() {
        @java.lang.Override
        public PurchaseTransaction parsePartialFrom(
            com.google.protobuf.CodedInputStream input,
            com.google.protobuf.ExtensionRegistryLite extensionRegistry)
            throws com.google.protobuf.InvalidProtocolBufferException {
          Builder builder = newBuilder();
          try {
            builder.mergeFrom(input, extensionRegistry);
          } catch (com.google.protobuf.InvalidProtocolBufferException e) {
            throw e.setUnfinishedMessage(builder.buildPartial());
          } catch (com.google.protobuf.UninitializedMessageException e) {
            throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial());
          } catch (java.io.IOException e) {
            throw new com.google.protobuf.InvalidProtocolBufferException(e)
                .setUnfinishedMessage(builder.buildPartial());
          }
          return builder.buildPartial();
        }
      };

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

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

  @java.lang.Override
  public com.google.cloud.recommendationengine.v1beta1.PurchaseTransaction
      getDefaultInstanceForType() {
    return DEFAULT_INSTANCE;
  }
}
