/*
 * Copyright 2026 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!
// NO CHECKED-IN PROTOBUF GENCODE
// source: google/storage/v2/storage.proto
// Protobuf Java Version: 4.33.2

package com.google.storage.v2;

/**
 *
 *
 * <pre>
 * All contexts of an object grouped by type.
 * </pre>
 *
 * Protobuf type {@code google.storage.v2.ObjectContexts}
 */
@com.google.protobuf.Generated
public final class ObjectContexts extends com.google.protobuf.GeneratedMessage
    implements
    // @@protoc_insertion_point(message_implements:google.storage.v2.ObjectContexts)
    ObjectContextsOrBuilder {
  private static final long serialVersionUID = 0L;

  static {
    com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion(
        com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC,
        /* major= */ 4,
        /* minor= */ 33,
        /* patch= */ 2,
        /* suffix= */ "",
        "ObjectContexts");
  }

  // Use ObjectContexts.newBuilder() to construct.
  private ObjectContexts(com.google.protobuf.GeneratedMessage.Builder<?> builder) {
    super(builder);
  }

  private ObjectContexts() {}

  public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
    return com.google.storage.v2.StorageProto
        .internal_static_google_storage_v2_ObjectContexts_descriptor;
  }

  @SuppressWarnings({"rawtypes"})
  @java.lang.Override
  protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection(
      int number) {
    switch (number) {
      case 1:
        return internalGetCustom();
      default:
        throw new RuntimeException("Invalid map field number: " + number);
    }
  }

  @java.lang.Override
  protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
      internalGetFieldAccessorTable() {
    return com.google.storage.v2.StorageProto
        .internal_static_google_storage_v2_ObjectContexts_fieldAccessorTable
        .ensureFieldAccessorsInitialized(
            com.google.storage.v2.ObjectContexts.class,
            com.google.storage.v2.ObjectContexts.Builder.class);
  }

  public static final int CUSTOM_FIELD_NUMBER = 1;

  private static final class CustomDefaultEntryHolder {
    static final com.google.protobuf.MapEntry<
            java.lang.String, com.google.storage.v2.ObjectCustomContextPayload>
        defaultEntry =
            com.google.protobuf.MapEntry
                .<java.lang.String, com.google.storage.v2.ObjectCustomContextPayload>
                    newDefaultInstance(
                        com.google.storage.v2.StorageProto
                            .internal_static_google_storage_v2_ObjectContexts_CustomEntry_descriptor,
                        com.google.protobuf.WireFormat.FieldType.STRING,
                        "",
                        com.google.protobuf.WireFormat.FieldType.MESSAGE,
                        com.google.storage.v2.ObjectCustomContextPayload.getDefaultInstance());
  }

  @SuppressWarnings("serial")
  private com.google.protobuf.MapField<
          java.lang.String, com.google.storage.v2.ObjectCustomContextPayload>
      custom_;

  private com.google.protobuf.MapField<
          java.lang.String, com.google.storage.v2.ObjectCustomContextPayload>
      internalGetCustom() {
    if (custom_ == null) {
      return com.google.protobuf.MapField.emptyMapField(CustomDefaultEntryHolder.defaultEntry);
    }
    return custom_;
  }

  public int getCustomCount() {
    return internalGetCustom().getMap().size();
  }

  /**
   *
   *
   * <pre>
   * Optional. User-defined object contexts.
   * The maximum key or value size is `256` characters.
   * The maximum number of entries is `50`.
   * The maximum total serialized size of all entries is `25KiB`.
   * </pre>
   *
   * <code>
   * map&lt;string, .google.storage.v2.ObjectCustomContextPayload&gt; custom = 1 [(.google.api.field_behavior) = OPTIONAL];
   * </code>
   */
  @java.lang.Override
  public boolean containsCustom(java.lang.String key) {
    if (key == null) {
      throw new NullPointerException("map key");
    }
    return internalGetCustom().getMap().containsKey(key);
  }

  /** Use {@link #getCustomMap()} instead. */
  @java.lang.Override
  @java.lang.Deprecated
  public java.util.Map<java.lang.String, com.google.storage.v2.ObjectCustomContextPayload>
      getCustom() {
    return getCustomMap();
  }

  /**
   *
   *
   * <pre>
   * Optional. User-defined object contexts.
   * The maximum key or value size is `256` characters.
   * The maximum number of entries is `50`.
   * The maximum total serialized size of all entries is `25KiB`.
   * </pre>
   *
   * <code>
   * map&lt;string, .google.storage.v2.ObjectCustomContextPayload&gt; custom = 1 [(.google.api.field_behavior) = OPTIONAL];
   * </code>
   */
  @java.lang.Override
  public java.util.Map<java.lang.String, com.google.storage.v2.ObjectCustomContextPayload>
      getCustomMap() {
    return internalGetCustom().getMap();
  }

  /**
   *
   *
   * <pre>
   * Optional. User-defined object contexts.
   * The maximum key or value size is `256` characters.
   * The maximum number of entries is `50`.
   * The maximum total serialized size of all entries is `25KiB`.
   * </pre>
   *
   * <code>
   * map&lt;string, .google.storage.v2.ObjectCustomContextPayload&gt; custom = 1 [(.google.api.field_behavior) = OPTIONAL];
   * </code>
   */
  @java.lang.Override
  public /* nullable */ com.google.storage.v2.ObjectCustomContextPayload getCustomOrDefault(
      java.lang.String key,
      /* nullable */
      com.google.storage.v2.ObjectCustomContextPayload defaultValue) {
    if (key == null) {
      throw new NullPointerException("map key");
    }
    java.util.Map<java.lang.String, com.google.storage.v2.ObjectCustomContextPayload> map =
        internalGetCustom().getMap();
    return map.containsKey(key) ? map.get(key) : defaultValue;
  }

  /**
   *
   *
   * <pre>
   * Optional. User-defined object contexts.
   * The maximum key or value size is `256` characters.
   * The maximum number of entries is `50`.
   * The maximum total serialized size of all entries is `25KiB`.
   * </pre>
   *
   * <code>
   * map&lt;string, .google.storage.v2.ObjectCustomContextPayload&gt; custom = 1 [(.google.api.field_behavior) = OPTIONAL];
   * </code>
   */
  @java.lang.Override
  public com.google.storage.v2.ObjectCustomContextPayload getCustomOrThrow(java.lang.String key) {
    if (key == null) {
      throw new NullPointerException("map key");
    }
    java.util.Map<java.lang.String, com.google.storage.v2.ObjectCustomContextPayload> map =
        internalGetCustom().getMap();
    if (!map.containsKey(key)) {
      throw new java.lang.IllegalArgumentException();
    }
    return map.get(key);
  }

  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 {
    com.google.protobuf.GeneratedMessage.serializeStringMapTo(
        output, internalGetCustom(), CustomDefaultEntryHolder.defaultEntry, 1);
    getUnknownFields().writeTo(output);
  }

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

    size = 0;
    for (java.util.Map.Entry<java.lang.String, com.google.storage.v2.ObjectCustomContextPayload>
        entry : internalGetCustom().getMap().entrySet()) {
      com.google.protobuf.MapEntry<
              java.lang.String, com.google.storage.v2.ObjectCustomContextPayload>
          custom__ =
              CustomDefaultEntryHolder.defaultEntry
                  .newBuilderForType()
                  .setKey(entry.getKey())
                  .setValue(entry.getValue())
                  .build();
      size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, custom__);
    }
    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.storage.v2.ObjectContexts)) {
      return super.equals(obj);
    }
    com.google.storage.v2.ObjectContexts other = (com.google.storage.v2.ObjectContexts) obj;

    if (!internalGetCustom().equals(other.internalGetCustom())) 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();
    if (!internalGetCustom().getMap().isEmpty()) {
      hash = (37 * hash) + CUSTOM_FIELD_NUMBER;
      hash = (53 * hash) + internalGetCustom().hashCode();
    }
    hash = (29 * hash) + getUnknownFields().hashCode();
    memoizedHashCode = hash;
    return hash;
  }

  public static com.google.storage.v2.ObjectContexts parseFrom(java.nio.ByteBuffer data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

  public static com.google.storage.v2.ObjectContexts parseFrom(
      java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }

  public static com.google.storage.v2.ObjectContexts parseFrom(com.google.protobuf.ByteString data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

  public static com.google.storage.v2.ObjectContexts 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.storage.v2.ObjectContexts parseFrom(byte[] data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

  public static com.google.storage.v2.ObjectContexts parseFrom(
      byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }

  public static com.google.storage.v2.ObjectContexts parseFrom(java.io.InputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input);
  }

  public static com.google.storage.v2.ObjectContexts parseFrom(
      java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessage.parseWithIOException(
        PARSER, input, extensionRegistry);
  }

  public static com.google.storage.v2.ObjectContexts parseDelimitedFrom(java.io.InputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input);
  }

  public static com.google.storage.v2.ObjectContexts parseDelimitedFrom(
      java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(
        PARSER, input, extensionRegistry);
  }

  public static com.google.storage.v2.ObjectContexts parseFrom(
      com.google.protobuf.CodedInputStream input) throws java.io.IOException {
    return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input);
  }

  public static com.google.storage.v2.ObjectContexts parseFrom(
      com.google.protobuf.CodedInputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessage.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.storage.v2.ObjectContexts 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.GeneratedMessage.BuilderParent parent) {
    Builder builder = new Builder(parent);
    return builder;
  }

  /**
   *
   *
   * <pre>
   * All contexts of an object grouped by type.
   * </pre>
   *
   * Protobuf type {@code google.storage.v2.ObjectContexts}
   */
  public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder<Builder>
      implements
      // @@protoc_insertion_point(builder_implements:google.storage.v2.ObjectContexts)
      com.google.storage.v2.ObjectContextsOrBuilder {
    public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
      return com.google.storage.v2.StorageProto
          .internal_static_google_storage_v2_ObjectContexts_descriptor;
    }

    @SuppressWarnings({"rawtypes"})
    protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection(
        int number) {
      switch (number) {
        case 1:
          return internalGetCustom();
        default:
          throw new RuntimeException("Invalid map field number: " + number);
      }
    }

    @SuppressWarnings({"rawtypes"})
    protected com.google.protobuf.MapFieldReflectionAccessor internalGetMutableMapFieldReflection(
        int number) {
      switch (number) {
        case 1:
          return internalGetMutableCustom();
        default:
          throw new RuntimeException("Invalid map field number: " + number);
      }
    }

    @java.lang.Override
    protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
        internalGetFieldAccessorTable() {
      return com.google.storage.v2.StorageProto
          .internal_static_google_storage_v2_ObjectContexts_fieldAccessorTable
          .ensureFieldAccessorsInitialized(
              com.google.storage.v2.ObjectContexts.class,
              com.google.storage.v2.ObjectContexts.Builder.class);
    }

    // Construct using com.google.storage.v2.ObjectContexts.newBuilder()
    private Builder() {}

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

    @java.lang.Override
    public Builder clear() {
      super.clear();
      bitField0_ = 0;
      internalGetMutableCustom().clear();
      return this;
    }

    @java.lang.Override
    public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
      return com.google.storage.v2.StorageProto
          .internal_static_google_storage_v2_ObjectContexts_descriptor;
    }

    @java.lang.Override
    public com.google.storage.v2.ObjectContexts getDefaultInstanceForType() {
      return com.google.storage.v2.ObjectContexts.getDefaultInstance();
    }

    @java.lang.Override
    public com.google.storage.v2.ObjectContexts build() {
      com.google.storage.v2.ObjectContexts result = buildPartial();
      if (!result.isInitialized()) {
        throw newUninitializedMessageException(result);
      }
      return result;
    }

    @java.lang.Override
    public com.google.storage.v2.ObjectContexts buildPartial() {
      com.google.storage.v2.ObjectContexts result = new com.google.storage.v2.ObjectContexts(this);
      if (bitField0_ != 0) {
        buildPartial0(result);
      }
      onBuilt();
      return result;
    }

    private void buildPartial0(com.google.storage.v2.ObjectContexts result) {
      int from_bitField0_ = bitField0_;
      if (((from_bitField0_ & 0x00000001) != 0)) {
        result.custom_ = internalGetCustom().build(CustomDefaultEntryHolder.defaultEntry);
      }
    }

    @java.lang.Override
    public Builder mergeFrom(com.google.protobuf.Message other) {
      if (other instanceof com.google.storage.v2.ObjectContexts) {
        return mergeFrom((com.google.storage.v2.ObjectContexts) other);
      } else {
        super.mergeFrom(other);
        return this;
      }
    }

    public Builder mergeFrom(com.google.storage.v2.ObjectContexts other) {
      if (other == com.google.storage.v2.ObjectContexts.getDefaultInstance()) return this;
      internalGetMutableCustom().mergeFrom(other.internalGetCustom());
      bitField0_ |= 0x00000001;
      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:
              {
                com.google.protobuf.MapEntry<
                        java.lang.String, com.google.storage.v2.ObjectCustomContextPayload>
                    custom__ =
                        input.readMessage(
                            CustomDefaultEntryHolder.defaultEntry.getParserForType(),
                            extensionRegistry);
                internalGetMutableCustom()
                    .ensureBuilderMap()
                    .put(custom__.getKey(), custom__.getValue());
                bitField0_ |= 0x00000001;
                break;
              } // case 10
            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 static final class CustomConverter
        implements com.google.protobuf.MapFieldBuilder.Converter<
            java.lang.String,
            com.google.storage.v2.ObjectCustomContextPayloadOrBuilder,
            com.google.storage.v2.ObjectCustomContextPayload> {
      @java.lang.Override
      public com.google.storage.v2.ObjectCustomContextPayload build(
          com.google.storage.v2.ObjectCustomContextPayloadOrBuilder val) {
        if (val instanceof com.google.storage.v2.ObjectCustomContextPayload) {
          return (com.google.storage.v2.ObjectCustomContextPayload) val;
        }
        return ((com.google.storage.v2.ObjectCustomContextPayload.Builder) val).build();
      }

      @java.lang.Override
      public com.google.protobuf.MapEntry<
              java.lang.String, com.google.storage.v2.ObjectCustomContextPayload>
          defaultEntry() {
        return CustomDefaultEntryHolder.defaultEntry;
      }
    }
    ;

    private static final CustomConverter customConverter = new CustomConverter();

    private com.google.protobuf.MapFieldBuilder<
            java.lang.String,
            com.google.storage.v2.ObjectCustomContextPayloadOrBuilder,
            com.google.storage.v2.ObjectCustomContextPayload,
            com.google.storage.v2.ObjectCustomContextPayload.Builder>
        custom_;

    private com.google.protobuf.MapFieldBuilder<
            java.lang.String,
            com.google.storage.v2.ObjectCustomContextPayloadOrBuilder,
            com.google.storage.v2.ObjectCustomContextPayload,
            com.google.storage.v2.ObjectCustomContextPayload.Builder>
        internalGetCustom() {
      if (custom_ == null) {
        return new com.google.protobuf.MapFieldBuilder<>(customConverter);
      }
      return custom_;
    }

    private com.google.protobuf.MapFieldBuilder<
            java.lang.String,
            com.google.storage.v2.ObjectCustomContextPayloadOrBuilder,
            com.google.storage.v2.ObjectCustomContextPayload,
            com.google.storage.v2.ObjectCustomContextPayload.Builder>
        internalGetMutableCustom() {
      if (custom_ == null) {
        custom_ = new com.google.protobuf.MapFieldBuilder<>(customConverter);
      }
      bitField0_ |= 0x00000001;
      onChanged();
      return custom_;
    }

    public int getCustomCount() {
      return internalGetCustom().ensureBuilderMap().size();
    }

    /**
     *
     *
     * <pre>
     * Optional. User-defined object contexts.
     * The maximum key or value size is `256` characters.
     * The maximum number of entries is `50`.
     * The maximum total serialized size of all entries is `25KiB`.
     * </pre>
     *
     * <code>
     * map&lt;string, .google.storage.v2.ObjectCustomContextPayload&gt; custom = 1 [(.google.api.field_behavior) = OPTIONAL];
     * </code>
     */
    @java.lang.Override
    public boolean containsCustom(java.lang.String key) {
      if (key == null) {
        throw new NullPointerException("map key");
      }
      return internalGetCustom().ensureBuilderMap().containsKey(key);
    }

    /** Use {@link #getCustomMap()} instead. */
    @java.lang.Override
    @java.lang.Deprecated
    public java.util.Map<java.lang.String, com.google.storage.v2.ObjectCustomContextPayload>
        getCustom() {
      return getCustomMap();
    }

    /**
     *
     *
     * <pre>
     * Optional. User-defined object contexts.
     * The maximum key or value size is `256` characters.
     * The maximum number of entries is `50`.
     * The maximum total serialized size of all entries is `25KiB`.
     * </pre>
     *
     * <code>
     * map&lt;string, .google.storage.v2.ObjectCustomContextPayload&gt; custom = 1 [(.google.api.field_behavior) = OPTIONAL];
     * </code>
     */
    @java.lang.Override
    public java.util.Map<java.lang.String, com.google.storage.v2.ObjectCustomContextPayload>
        getCustomMap() {
      return internalGetCustom().getImmutableMap();
    }

    /**
     *
     *
     * <pre>
     * Optional. User-defined object contexts.
     * The maximum key or value size is `256` characters.
     * The maximum number of entries is `50`.
     * The maximum total serialized size of all entries is `25KiB`.
     * </pre>
     *
     * <code>
     * map&lt;string, .google.storage.v2.ObjectCustomContextPayload&gt; custom = 1 [(.google.api.field_behavior) = OPTIONAL];
     * </code>
     */
    @java.lang.Override
    public /* nullable */ com.google.storage.v2.ObjectCustomContextPayload getCustomOrDefault(
        java.lang.String key,
        /* nullable */
        com.google.storage.v2.ObjectCustomContextPayload defaultValue) {
      if (key == null) {
        throw new NullPointerException("map key");
      }
      java.util.Map<java.lang.String, com.google.storage.v2.ObjectCustomContextPayloadOrBuilder>
          map = internalGetMutableCustom().ensureBuilderMap();
      return map.containsKey(key) ? customConverter.build(map.get(key)) : defaultValue;
    }

    /**
     *
     *
     * <pre>
     * Optional. User-defined object contexts.
     * The maximum key or value size is `256` characters.
     * The maximum number of entries is `50`.
     * The maximum total serialized size of all entries is `25KiB`.
     * </pre>
     *
     * <code>
     * map&lt;string, .google.storage.v2.ObjectCustomContextPayload&gt; custom = 1 [(.google.api.field_behavior) = OPTIONAL];
     * </code>
     */
    @java.lang.Override
    public com.google.storage.v2.ObjectCustomContextPayload getCustomOrThrow(java.lang.String key) {
      if (key == null) {
        throw new NullPointerException("map key");
      }
      java.util.Map<java.lang.String, com.google.storage.v2.ObjectCustomContextPayloadOrBuilder>
          map = internalGetMutableCustom().ensureBuilderMap();
      if (!map.containsKey(key)) {
        throw new java.lang.IllegalArgumentException();
      }
      return customConverter.build(map.get(key));
    }

    public Builder clearCustom() {
      bitField0_ = (bitField0_ & ~0x00000001);
      internalGetMutableCustom().clear();
      return this;
    }

    /**
     *
     *
     * <pre>
     * Optional. User-defined object contexts.
     * The maximum key or value size is `256` characters.
     * The maximum number of entries is `50`.
     * The maximum total serialized size of all entries is `25KiB`.
     * </pre>
     *
     * <code>
     * map&lt;string, .google.storage.v2.ObjectCustomContextPayload&gt; custom = 1 [(.google.api.field_behavior) = OPTIONAL];
     * </code>
     */
    public Builder removeCustom(java.lang.String key) {
      if (key == null) {
        throw new NullPointerException("map key");
      }
      internalGetMutableCustom().ensureBuilderMap().remove(key);
      return this;
    }

    /** Use alternate mutation accessors instead. */
    @java.lang.Deprecated
    public java.util.Map<java.lang.String, com.google.storage.v2.ObjectCustomContextPayload>
        getMutableCustom() {
      bitField0_ |= 0x00000001;
      return internalGetMutableCustom().ensureMessageMap();
    }

    /**
     *
     *
     * <pre>
     * Optional. User-defined object contexts.
     * The maximum key or value size is `256` characters.
     * The maximum number of entries is `50`.
     * The maximum total serialized size of all entries is `25KiB`.
     * </pre>
     *
     * <code>
     * map&lt;string, .google.storage.v2.ObjectCustomContextPayload&gt; custom = 1 [(.google.api.field_behavior) = OPTIONAL];
     * </code>
     */
    public Builder putCustom(
        java.lang.String key, com.google.storage.v2.ObjectCustomContextPayload value) {
      if (key == null) {
        throw new NullPointerException("map key");
      }
      if (value == null) {
        throw new NullPointerException("map value");
      }
      internalGetMutableCustom().ensureBuilderMap().put(key, value);
      bitField0_ |= 0x00000001;
      return this;
    }

    /**
     *
     *
     * <pre>
     * Optional. User-defined object contexts.
     * The maximum key or value size is `256` characters.
     * The maximum number of entries is `50`.
     * The maximum total serialized size of all entries is `25KiB`.
     * </pre>
     *
     * <code>
     * map&lt;string, .google.storage.v2.ObjectCustomContextPayload&gt; custom = 1 [(.google.api.field_behavior) = OPTIONAL];
     * </code>
     */
    public Builder putAllCustom(
        java.util.Map<java.lang.String, com.google.storage.v2.ObjectCustomContextPayload> values) {
      for (java.util.Map.Entry<java.lang.String, com.google.storage.v2.ObjectCustomContextPayload>
          e : values.entrySet()) {
        if (e.getKey() == null || e.getValue() == null) {
          throw new NullPointerException();
        }
      }
      internalGetMutableCustom().ensureBuilderMap().putAll(values);
      bitField0_ |= 0x00000001;
      return this;
    }

    /**
     *
     *
     * <pre>
     * Optional. User-defined object contexts.
     * The maximum key or value size is `256` characters.
     * The maximum number of entries is `50`.
     * The maximum total serialized size of all entries is `25KiB`.
     * </pre>
     *
     * <code>
     * map&lt;string, .google.storage.v2.ObjectCustomContextPayload&gt; custom = 1 [(.google.api.field_behavior) = OPTIONAL];
     * </code>
     */
    public com.google.storage.v2.ObjectCustomContextPayload.Builder putCustomBuilderIfAbsent(
        java.lang.String key) {
      java.util.Map<java.lang.String, com.google.storage.v2.ObjectCustomContextPayloadOrBuilder>
          builderMap = internalGetMutableCustom().ensureBuilderMap();
      com.google.storage.v2.ObjectCustomContextPayloadOrBuilder entry = builderMap.get(key);
      if (entry == null) {
        entry = com.google.storage.v2.ObjectCustomContextPayload.newBuilder();
        builderMap.put(key, entry);
      }
      if (entry instanceof com.google.storage.v2.ObjectCustomContextPayload) {
        entry = ((com.google.storage.v2.ObjectCustomContextPayload) entry).toBuilder();
        builderMap.put(key, entry);
      }
      return (com.google.storage.v2.ObjectCustomContextPayload.Builder) entry;
    }

    // @@protoc_insertion_point(builder_scope:google.storage.v2.ObjectContexts)
  }

  // @@protoc_insertion_point(class_scope:google.storage.v2.ObjectContexts)
  private static final com.google.storage.v2.ObjectContexts DEFAULT_INSTANCE;

  static {
    DEFAULT_INSTANCE = new com.google.storage.v2.ObjectContexts();
  }

  public static com.google.storage.v2.ObjectContexts getDefaultInstance() {
    return DEFAULT_INSTANCE;
  }

  private static final com.google.protobuf.Parser<ObjectContexts> PARSER =
      new com.google.protobuf.AbstractParser<ObjectContexts>() {
        @java.lang.Override
        public ObjectContexts 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<ObjectContexts> parser() {
    return PARSER;
  }

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

  @java.lang.Override
  public com.google.storage.v2.ObjectContexts getDefaultInstanceForType() {
    return DEFAULT_INSTANCE;
  }
}
