text:
// Copyright 2018 The Bazel Authors. All rights reserved.
//
// 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
//
//    http://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.
package com.google.devtools.build.lib.worker;

import static com.google.common.truth.Truth.assertThat;

import com.google.common.collect.ImmutableSet;
import com.google.devtools.build.lib.actions.util.ActionsTestUtil;
import com.google.devtools.build.lib.sandbox.SandboxHelpers.SandboxInputs;
import com.google.devtools.build.lib.sandbox.SandboxHelpers.SandboxOutputs;
import com.google.devtools.build.lib.testutil.TestUtils;
import com.google.devtools.build.lib.vfs.DigestHashFunction;
import com.google.devtools.build.lib.vfs.FileSystem;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/** Tests for {@link WorkerExecRoot}. */
@RunWith(JUnit4.class)
public class WorkerExecRootTest {
  private FileSystem fileSystem;
  private Path testRoot;
  private Path workspaceDir;
  private Path sandboxDir;
  private Path execRoot;

  @Before
  public final void setupTestDirs() throws IOException {
    fileSystem = new InMemoryFileSystem(DigestHashFunction.SHA256);
    testRoot = fileSystem.getPath(TestUtils.tmpDir());
    testRoot.createDirectoryAndParents();

    workspaceDir = testRoot.getRelative("workspace");
    workspaceDir.createDirectory();
    sandboxDir = testRoot.getRelative("sandbox");
    sandboxDir.createDirectory();
    execRoot = sandboxDir.getRelative("execroot/__main__");
    execRoot.createDirectoryAndParents();
  }

  @Test
  public void cleanFileSystem() throws Exception {
    SandboxHelper sandboxHelper =
        new SandboxHelper(workspaceDir, execRoot)
            .addAndCreateInputFile("worker.sh", "worker.sh", "#!/bin/bash")
            .addOutput("very/output.txt")
            .addWorkerFile("worker.sh");
    Path workerSh = workspaceDir.getRelative("worker.sh");

    WorkerExecRoot workerExecRoot = new WorkerExecRoot(execRoot);
    workerExecRoot.createFileSystem(
        sandboxHelper.getWorkerFiles(),
        sandboxHelper.getSandboxInputs(),
        sandboxHelper.getSandboxOutputs());

    // Pretend to do some work inside the execRoot.
    execRoot.getRelative("tempdir").createDirectory();
    FileSystemUtils.createEmptyFile(execRoot.getRelative("very/output.txt"));
    FileSystemUtils.createEmptyFile(execRoot.getRelative("temp.txt"));
    // Modify the worker.sh so that we're able to detect whether it gets rewritten or not.
    FileSystemUtils.writeContentAsLatin1(workerSh, "#!/bin/sh");

    // Reuse the same execRoot.
    workerExecRoot.createFileSystem(
        sandboxHelper.getWorkerFiles(),
        sandboxHelper.getSandboxInputs(),
        sandboxHelper.getSandboxOutputs());

    assertThat(execRoot.getRelative("worker.sh").exists()).isTrue();
    assertThat(
            FileSystemUtils.readContent(
                execRoot.getRelative("worker.sh"), Charset.defaultCharset()))
        .isEqualTo("#!/bin/sh");
    assertThat(execRoot.getRelative("tempdir").exists()).isFalse();
    assertThat(execRoot.getRelative("very/output.txt").exists()).isFalse();
    assertThat(execRoot.getRelative("temp.txt").exists()).isFalse();
  }

  @Test
  public void createsAndCleansInputSymlinks() throws Exception {
    // Simulate existing symlinks in the exec root to check that `WorkerExecRoot` correctly deletes
    // the unnecessary ones and updates the ones that don't point to the right target.
    SandboxHelper sandboxHelper =
        new SandboxHelper(workspaceDir, execRoot)
            .createSymlink("dir/input_symlink_1", "old_content")
            .createSymlink("dir/input_symlink_2", "unchanged")
            .createSymlink("dir/input_symlink_3", "whatever")
            .addSymlink("dir/input_symlink_1", "new_content")
            .addSymlink("dir/input_symlink_2", "unchanged");

    WorkerExecRoot workerExecRoot = new WorkerExecRoot(execRoot);

    // This should update the `input_symlink_{1,2,3}` according to `SandboxInputs`, i.e., update the
    // first/second (alternatively leave the second unchanged) and delete the third.
    workerExecRoot.createFileSystem(
        sandboxHelper.getWorkerFiles(),
        sandboxHelper.getSandboxInputs(),
        sandboxHelper.getSandboxOutputs());

    assertThat(execRoot.getRelative("dir/input_symlink_1").readSymbolicLink())
        .isEqualTo(PathFragment.create("new_content"));
    assertThat(execRoot.getRelative("dir/input_symlink_2").readSymbolicLink())
        .isEqualTo(PathFragment.create("unchanged"));
    assertThat(execRoot.getRelative("dir/input_symlink_3").exists()).isFalse();
  }

  @Test
  public void createsOutputDirs() throws Exception {
    SandboxHelper sandboxHelper =
        new SandboxHelper(workspaceDir, execRoot)
            .addOutput("dir/foo/bar_kt.jar")
            .addOutput("dir/foo/bar_kt.jdeps")
            .addOutput("dir/foo/bar_kt-sources.jar")
            .addOutputDir("dir/foo/_kotlinc/bar_kt_jvm/bar_kt_sourcegenfiles")
            .addOutputDir("dir/foo/_kotlinc/bar_kt_jvm/bar_kt_classes")
            .addOutputDir("dir/foo/_kotlinc/bar_kt_jvm/bar_kt_temp")
            .addOutputDir("dir/foo/_kotlinc/bar_kt_jvm/bar_kt_generated_classes");
    WorkerExecRoot workerExecRoot = new WorkerExecRoot(execRoot);
    workerExecRoot.createFileSystem(
        sandboxHelper.getWorkerFiles(),
        sandboxHelper.getSandboxInputs(),
        sandboxHelper.getSandboxOutputs());

    assertThat(execRoot.getRelative("dir/foo/_kotlinc/bar_kt_jvm/bar_kt_sourcegenfiles").exists())
        .isTrue();
    assertThat(execRoot.getRelative("dir/foo/_kotlinc/bar_kt_jvm/bar_kt_classes").exists())
        .isTrue();
    assertThat(execRoot.getRelative("dir/foo/_kotlinc/bar_kt_jvm/bar_kt_temp").exists()).isTrue();
    assertThat(
            execRoot.getRelative("dir/foo/_kotlinc/bar_kt_jvm/bar_kt_generated_classes").exists())
        .isTrue();
  }

  @Test
  public void workspaceFilesAreNotDeleted() throws Exception {
    // We want to check that `WorkerExecRoot` deletes pre-existing symlinks if they're not in the
    // `SandboxInputs`, but it does not delete the files that the symlinks point to (i.e., the files
    // in the workspace directory).
    Path neededWorkspaceFile = workspaceDir.getRelative("needed_file");
    Path otherWorkspaceFile = workspaceDir.getRelative("other_file");

    SandboxHelper sandboxHelper =
        new SandboxHelper(workspaceDir, execRoot)
            .addInputFile("needed_file", "needed_file")
            .createWorkspaceDirFile("needed_file", "needed workspace content")
            .createWorkspaceDirFile("other_file", "other workspace content")
            .createSymlink("needed_file", neededWorkspaceFile.getPathString())
            .createSymlink("other_file", otherWorkspaceFile.getPathString());

    WorkerExecRoot workerExecRoot = new WorkerExecRoot(execRoot);
    workerExecRoot.createFileSystem(
        sandboxHelper.getWorkerFiles(),
        sandboxHelper.getSandboxInputs(),
        sandboxHelper.getSandboxOutputs());

    assertThat(execRoot.getRelative("needed_file").readSymbolicLink())
        .isEqualTo(neededWorkspaceFile.asFragment());
    assertThat(execRoot.getRelative("other_file").exists()).isFalse();

    assertThat(FileSystemUtils.readContent(neededWorkspaceFile, Charset.defaultCharset()))
        .isEqualTo("needed workspace content");
    assertThat(FileSystemUtils.readContent(otherWorkspaceFile, Charset.defaultCharset()))
        .isEqualTo("other workspace content");
  }

  @Test
  public void recreatesEmptyFiles() throws Exception {
    // Simulate existing non-empty file in the exec root to check that `WorkerExecRoot` will clear
    // the contents as requested by `SandboxInputs`.
    // This is interesting, because the filepath is a key in `SandboxInputs`, but its value is
    // `null`, which means "create an empty file". So after `createFileSystem` the file should be
    // empty.
    SandboxHelper sandboxHelper =
        new SandboxHelper(workspaceDir, execRoot)
            .createExecRootFile("some_file", "some content")
            .addInputFile("some_file", null);

    WorkerExecRoot workerExecRoot = new WorkerExecRoot(sandboxHelper.execRoot);
    workerExecRoot.createFileSystem(
        sandboxHelper.getWorkerFiles(),
        sandboxHelper.getSandboxInputs(),
        sandboxHelper.getSandboxOutputs());

    assertThat(
            FileSystemUtils.readContent(
                execRoot.getRelative("some_file"), Charset.defaultCharset()))
        .isEmpty();
  }

  @Test
  public void createsAndDeletesSiblingExternalRepoFiles() throws Exception {
    // With the sibling repository layout, external repository source files are no longer symlinked
    // under <execroot>/external/<repo name>/<path>. Instead, they become *siblings* of the main
    // workspace files in that they're placed at <execroot>/../<repo name>/<path>. Simulate this
    // layout and check if inputs are correctly created and irrelevant symlinks are deleted.

    Path fooRepoDir = workspaceDir.getRelative("external_dir/foo");
    Path input1 = fooRepoDir.getRelative("bar/input1");
    Path input2 = fooRepoDir.getRelative("input2");
    Path random = fooRepoDir.getRelative("bar/random");

    SandboxHelper sandboxHelper =
        new SandboxHelper(workspaceDir, execRoot)
            .createWorkspaceDirFile("external_dir/foo/bar/input1", "This is input1.")
            .createWorkspaceDirFile("external_dir/foo/input2", "This is input2.")
            .createWorkspaceDirFile("external_dir/foo/bar/random", "This is random.")
            .createSymlink("../foo/bar/input1", input1.getPathString())
            .createSymlink("../foo/bar/random", random.getPathString())
            .addInputFile("../foo/bar/input1", input1.getPathString())
            .addInputFile("../foo/input2", input2.getPathString());

    WorkerExecRoot workerExecRoot = new WorkerExecRoot(execRoot);
    workerExecRoot.createFileSystem(
        sandboxHelper.getWorkerFiles(),
        sandboxHelper.getSandboxInputs(),
        sandboxHelper.getSandboxOutputs());

    assertThat(execRoot.getRelative("../foo/bar/input1").readSymbolicLink())
        .isEqualTo(input1.asFragment());
    assertThat(execRoot.getRelative("../foo/input2").readSymbolicLink())
        .isEqualTo(input2.asFragment());
    assertThat(execRoot.getRelative("bar/random").exists()).isFalse();
  }

  /**
   * Helper class that sets up a sandbox in a more comprehensible way. Handles setting up
   * SandboxInputs and SandboxOutputs as well as creating related files.
   */
  private static class SandboxHelper {
    /** Map from workdir-relative input path to optional real file path. */
    private final Map<PathFragment, Path> inputs = new HashMap<>();

    private final Map<PathFragment, String> virtualInputs = new HashMap<>();
    private final Map<PathFragment, PathFragment> symlinks = new HashMap<>();
    private final Map<PathFragment, Path> workerFiles = new HashMap<>();
    private final List<PathFragment> outputFiles = new ArrayList<>();
    private final List<PathFragment> outputDirs = new ArrayList<>();

    private final Path workspaceDir;
    private final Path execRoot;

    public SandboxHelper(Path workspaceDir, Path execRoot) {
      this.workspaceDir = workspaceDir;
      this.execRoot = execRoot;
    }

    /**
     * Adds a regular input file at execRootPath under execRoot, with the real file at workspacePath
     * under workspaceDir.
     */
    public SandboxHelper addInputFile(String execRootPath, String workspacePath) {
      inputs.put(
          PathFragment.create(execRootPath),
          workspacePath != null ? workspaceDir.getRelative(workspacePath) : null);
      return this;
    }

    /**
     * Adds a regular input file at execRootPath under execRoot, with the real file at workspacePath
     * under workspaceDir. The real file gets created immediately and filled with {@code contents}.
     */
    public SandboxHelper addAndCreateInputFile(
        String execRootPath, String workspacePath, String contents) throws IOException {
      addInputFile(execRootPath, workspacePath);
      Path absPath = workspaceDir.getRelative(workspacePath);
      absPath.getParentDirectory().createDirectoryAndParents();
      FileSystemUtils.writeContentAsLatin1(absPath, contents);
      return this;
    }

    /** Adds a virtual input with some contents. */
    public SandboxHelper addAndCreateVirtualInput(String execRootPath, String contents) {
      virtualInputs.put(PathFragment.create(execRootPath), contents);
      return this;
    }

    /** Adds a symlink to the inputs. */
    public SandboxHelper addSymlink(String execRootPath, String linkTo) {
      symlinks.put(PathFragment.create(execRootPath), PathFragment.create(linkTo));
      return this;
    }

    /** Adds an output file without creating it. */
    public SandboxHelper addOutput(String execRootPath) {
      outputFiles.add(PathFragment.create(execRootPath));
      return this;
    }

    /** Adds an output directory without creating it. */
    public SandboxHelper addOutputDir(String execRootPath) {
      outputDirs.add(
          PathFragment.create(execRootPath.endsWith("/") ? execRootPath : execRootPath + "/"));
      return this;
    }

    /** Adds a worker file that is created under workspaceDir and referenced under execRoot. */
    public SandboxHelper addWorkerFile(String execRootPath) {
      Path absPath = workspaceDir.getRelative(execRootPath);
      workerFiles.put(PathFragment.create(execRootPath), absPath);
      return this;
    }

    /**
     * Adds a worker file that is created under workspaceDir and referenced under execRoot. Writes
     * the content under workspaceDir.
     */
    public SandboxHelper addAndCreateWorkerFile(String execRootPath, String contents)
        throws IOException {
      addWorkerFile(execRootPath);
      Path absPath = workspaceDir.getRelative(execRootPath);
      absPath.getParentDirectory().createDirectoryAndParents();
      FileSystemUtils.writeContentAsLatin1(absPath, contents);
      return this;
    }

    /** Creates a file with {@code contents} at {@code relPath} under execRoot. */
    public SandboxHelper createExecRootFile(String execRootPath, String contents)
        throws IOException {
      Path absPath = execRoot.getRelative(execRootPath);
      absPath.getParentDirectory().createDirectoryAndParents();
      FileSystemUtils.writeContentAsLatin1(absPath, contents);
      return this;
    }

    /** Creates a file with {@code contents} at {@code relPath} under execRoot. */
    public SandboxHelper createWorkspaceDirFile(String workspaceDirPath, String contents)
        throws IOException {
      Path absPath = workspaceDir.getRelative(workspaceDirPath);
      absPath.getParentDirectory().createDirectoryAndParents();
      FileSystemUtils.writeContentAsLatin1(absPath, contents);
      return this;
    }

    /**
     * Creates a symlink from within the execroot. The destination is just what's written into the
     * symlink and thus relative to the created symlink.
     */
    public SandboxHelper createSymlink(String execRootPath, String relativeDestination)
        throws IOException {
      Path fromPath = execRoot.getRelative(execRootPath);
      FileSystemUtils.ensureSymbolicLink(fromPath, relativeDestination);
      return this;
    }

    /**
     * Creates a symlink from within the execroot, and creates the target file with the given
     * contents. The destination is just what's written into the symlink and thus relative to the
     * created symlink.
     */
    public SandboxHelper createSymlinkWithContents(
        String execRootPath, String relativeDestination, String contents) throws IOException {
      createSymlink(execRootPath, relativeDestination);
      Path fromPath = execRoot.getRelative(execRootPath);
      Path toPath = fromPath.getRelative(relativeDestination);
      toPath.getParentDirectory().createDirectoryAndParents();
      FileSystemUtils.writeContentAsLatin1(toPath, contents);
      return this;
    }

    public SandboxInputs getSandboxInputs() {
      return new SandboxInputs(
          this.inputs,
          virtualInputs.entrySet().stream()
              .map(
                  entry ->
                      ActionsTestUtil.createVirtualActionInput(entry.getKey(), entry.getValue()))
              .collect(Collectors.toSet()),
          symlinks);
    }

    public SandboxOutputs getSandboxOutputs() {
      return SandboxOutputs.create(
          ImmutableSet.copyOf(this.outputFiles), ImmutableSet.copyOf(this.outputDirs));
    }

    public ImmutableSet<PathFragment> getWorkerFiles() {
      return ImmutableSet.copyOf(workerFiles.keySet());
    }
  }
}


text:
package com.platypus.android.tablet;

/**
 * Created by zeshengxi on 2/16/16.
 */

import android.util.Log;

import com.google.code.microlog4android.Level;
import com.google.code.microlog4android.LoggerFactory;
import com.google.code.microlog4android.appender.FileAppender;
import com.google.code.microlog4android.format.PatternFormatter;

import org.json.JSONObject;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * A logging class that creates vehicle logs in JSON format.
 *
 * This allows the creation of easily parsable and log messages and handles storing the log in a
 * standard location from which it can be downloaded.
 *
 * Example:
 * <pre>
 *     try {
 *         JSONObject entry = new JSONObject()
 *             .put("gain", new JSONObject()
 *                 .put("axis", axis)
 *                 .put("values", gains));
 *         logger.info(entry);
 *     } catch (JSONException e) {
 *         Log.w(TAG, "Failed to write gain to log file.");
 *     }
 * </pre>
 */
public class TabletLogger {
    private static final String TAG = TeleOpPanel.class.getSimpleName();

    /**
     * Internal logger object used to add entries to the log.
     */
    private static final com.google.code.microlog4android.Logger mLogger =
            LoggerFactory.getLogger();

    /**
     * Internal log appender that manages the output to a log file.
     */
    private FileAppender mFileAppender;

    /**
     * The default prefix for Platypus Vehicle data log files.
     */
    private static final String DEFAULT_LOG_PREFIX = "platypus-tablet_";

    /**
     * Constructs a default filename from the current date and time.
     *
     * @return the default filename for the current time.
     */
    private static String defaultFilename() {
        Date d = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");
        return DEFAULT_LOG_PREFIX + sdf.format(d) + ".txt";
    }

    /**
     * Create a new vehicle log file.
     */
    public TabletLogger() {
        // Set up logging format to include time, tag, and value.
        PatternFormatter formatter = new PatternFormatter();
        formatter.setPattern("%r %d %m %T");

        // Set up an output stream for the vehicle log file.
        String logFilename = defaultFilename();
        mFileAppender = new FileAppender();
        mFileAppender.setFileName(logFilename);
        mFileAppender.setAppend(true);
        mFileAppender.setFormatter(formatter);
        try {
            mFileAppender.open();
        } catch (IOException e) {
            Log.w(TAG, "Failed to open data log file: " + logFilename, e);
        }
        mLogger.addAppender(mFileAppender);
    }

    public synchronized void close() {
        // Remove the data log (a new one will be created on restart)
        if (mFileAppender != null) {
            try {
                mFileAppender.close();
                mFileAppender = null;
            } catch (IOException e) {
                Log.e(TAG, "Data log shutdown error", e);
            }
        }
    }

    /**
     * Creates a log entry from the specified JSON object.
     * @param obj
     */
    public synchronized void log(Level level, JSONObject obj) {
        mLogger.log(level, obj.toString());
    }

    public synchronized void debug(JSONObject obj) {
        log(Level.DEBUG, obj);
    }

    public synchronized void error(JSONObject obj) {
        log(Level.ERROR, obj);
    }

    public synchronized void fatal(JSONObject obj) {
        log(Level.FATAL, obj);
    }

    public synchronized void info(JSONObject obj) {
        log(Level.INFO, obj);
    }

    public synchronized void warn(JSONObject obj) {
        log(Level.WARN, obj);
    }
}

redpajama_set_name: RedPajamaGithub


text:
import Ember from 'ember';

import { moduleFor, test } from 'ember-qunit';

moduleFor('controller:abstract', 'Unit | Controller | abstract', {
  // Specify the other units that are required for this test.
  // needs: ['route:abstract']
});

test('Basic creation test', function(assert) {
  let controller = this.subject({
    send: Ember.K,
    initVisibleColumns: Ember.K
  });

  assert.ok(controller.name);
  assert.ok(controller.crumbObserver);
  assert.ok(controller.setBreadcrumbs);
  assert.ok(controller.loaded);
});

test('init test', function(assert) {
  assert.expect(1);

  this.subject({
    send: function (name) {
      assert.equal(name, "setBreadcrumbs");
    }
  });
});

test('crumbObserver test', function(assert) {
  assert.expect(1 + 1); // Init and fired

  let controller = this.subject({
    send: function (name) {
      assert.equal(name, "setBreadcrumbs");
    }
  });

  controller.set("breadcrumbs", []);
});

test('setBreadcrumbs test', function(assert) {
  let testName = "Abc", // Because all controllers are pointing to the leaf rout
      testBreadCrumbs = [];

  assert.expect(3);
  this.subject({
    name: testName,
    breadcrumbs: testBreadCrumbs,
    send: function (name, crumbs) {
      assert.equal(name, "setBreadcrumbs");
      assert.ok(crumbs.hasOwnProperty(testName));
      assert.equal(crumbs[testName], testBreadCrumbs);
    }
  });
});


text:
// <auto-generated>
//     Generated by the protocol buffer compiler.  DO NOT EDIT!
//     source: google/cloud/retail/v2/catalog_service.proto
// </auto-generated>
#pragma warning disable 1591, 0612, 3021
#region Designer generated code

using pb = global::Google.Protobuf;
using pbc = global::Google.Protobuf.Collections;
using pbr = global::Google.Protobuf.Reflection;
using scg = global::System.Collections.Generic;
namespace Google.Cloud.Retail.V2 {

  /// Holder for reflection information generated from google/cloud/retail/v2/catalog_service.proto
  public static partial class CatalogServiceReflection {

    #region Descriptor
    /// File descriptor for google/cloud/retail/v2/catalog_service.proto
    public static pbr::FileDescriptor Descriptor {
      get { return descriptor; }
    }
    private static pbr::FileDescriptor descriptor;

    static CatalogServiceReflection() {
      byte[] descriptorData = global::System.Convert.FromBase64String(
          string.Concat(
            "Cixnb29nbGUvY2xvdWQvcmV0YWlsL3YyL2NhdGFsb2dfc2VydmljZS5wcm90",
            "bxIWZ29vZ2xlLmNsb3VkLnJldGFpbC52MhocZ29vZ2xlL2FwaS9hbm5vdGF0",
            "aW9ucy5wcm90bxoXZ29vZ2xlL2FwaS9jbGllbnQucHJvdG8aH2dvb2dsZS9h",
            "cGkvZmllbGRfYmVoYXZpb3IucHJvdG8aGWdvb2dsZS9hcGkvcmVzb3VyY2Uu",
            "cHJvdG8aJGdvb2dsZS9jbG91ZC9yZXRhaWwvdjIvY2F0YWxvZy5wcm90bxob",
            "Z29vZ2xlL3Byb3RvYnVmL2VtcHR5LnByb3RvGiBnb29nbGUvcHJvdG9idWYv",
            "ZmllbGRfbWFzay5wcm90bxofZ29vZ2xlL3Byb3RvYnVmL3RpbWVzdGFtcC5w",
            "cm90byJ3ChNMaXN0Q2F0YWxvZ3NSZXF1ZXN0EjkKBnBhcmVudBgBIAEoCUIp",
            "4EEC+kEjCiFsb2NhdGlvbnMuZ29vZ2xlYXBpcy5jb20vTG9jYXRpb24SEQoJ",
            "cGFnZV9zaXplGAIgASgFEhIKCnBhZ2VfdG9rZW4YAyABKAkiYgoUTGlzdENh",
            "dGFsb2dzUmVzcG9uc2USMQoIY2F0YWxvZ3MYASADKAsyHy5nb29nbGUuY2xv",
            "dWQucmV0YWlsLnYyLkNhdGFsb2cSFwoPbmV4dF9wYWdlX3Rva2VuGAIgASgJ",
            "In4KFFVwZGF0ZUNhdGFsb2dSZXF1ZXN0EjUKB2NhdGFsb2cYASABKAsyHy5n",
            "b29nbGUuY2xvdWQucmV0YWlsLnYyLkNhdGFsb2dCA+BBAhIvCgt1cGRhdGVf",
            "bWFzaxgCIAEoCzIaLmdvb2dsZS5wcm90b2J1Zi5GaWVsZE1hc2sioQEKF1Nl",
            "dERlZmF1bHRCcmFuY2hSZXF1ZXN0EjMKB2NhdGFsb2cYASABKAlCIvpBHwod",
            "cmV0YWlsLmdvb2dsZWFwaXMuY29tL0NhdGFsb2cSNAoJYnJhbmNoX2lkGAIg",
            "ASgJQiH6QR4KHHJldGFpbC5nb29nbGVhcGlzLmNvbS9CcmFuY2gSDAoEbm90",
            "ZRgDIAEoCRINCgVmb3JjZRgEIAEoCCJOChdHZXREZWZhdWx0QnJhbmNoUmVx",
            "dWVzdBIzCgdjYXRhbG9nGAEgASgJQiL6QR8KHXJldGFpbC5nb29nbGVhcGlz",
            "LmNvbS9DYXRhbG9nIokBChhHZXREZWZhdWx0QnJhbmNoUmVzcG9uc2USMQoG",
            "YnJhbmNoGAEgASgJQiH6QR4KHHJldGFpbC5nb29nbGVhcGlzLmNvbS9CcmFu",
            "Y2gSLAoIc2V0X3RpbWUYAiABKAsyGi5nb29nbGUucHJvdG9idWYuVGltZXN0",
            "YW1wEgwKBG5vdGUYAyABKAkyxQYKDkNhdGFsb2dTZXJ2aWNlEqgBCgxMaXN0",
            "Q2F0YWxvZ3MSKy5nb29nbGUuY2xvdWQucmV0YWlsLnYyLkxpc3RDYXRhbG9n",
            "c1JlcXVlc3QaLC5nb29nbGUuY2xvdWQucmV0YWlsLnYyLkxpc3RDYXRhbG9n",
            "c1Jlc3BvbnNlIj2C0+STAi4SLC92Mi97cGFyZW50PXByb2plY3RzLyovbG9j",
            "YXRpb25zLyp9L2NhdGFsb2dz2kEGcGFyZW50ErsBCg1VcGRhdGVDYXRhbG9n",
            "EiwuZ29vZ2xlLmNsb3VkLnJldGFpbC52Mi5VcGRhdGVDYXRhbG9nUmVxdWVz",
            "dBofLmdvb2dsZS5jbG91ZC5yZXRhaWwudjIuQ2F0YWxvZyJbgtPkkwI/MjQv",
            "djIve2NhdGFsb2cubmFtZT1wcm9qZWN0cy8qL2xvY2F0aW9ucy8qL2NhdGFs",
            "b2dzLyp9OgdjYXRhbG9n2kETY2F0YWxvZyx1cGRhdGVfbWFzaxKyAQoQU2V0",
            "RGVmYXVsdEJyYW5jaBIvLmdvb2dsZS5jbG91ZC5yZXRhaWwudjIuU2V0RGVm",
            "YXVsdEJyYW5jaFJlcXVlc3QaFi5nb29nbGUucHJvdG9idWYuRW1wdHkiVYLT",
            "5JMCRSJAL3YyL3tjYXRhbG9nPXByb2plY3RzLyovbG9jYXRpb25zLyovY2F0",
            "YWxvZ3MvKn06c2V0RGVmYXVsdEJyYW5jaDoBKtpBB2NhdGFsb2cSyQEKEEdl",
            "dERlZmF1bHRCcmFuY2gSLy5nb29nbGUuY2xvdWQucmV0YWlsLnYyLkdldERl",
            "ZmF1bHRCcmFuY2hSZXF1ZXN0GjAuZ29vZ2xlLmNsb3VkLnJldGFpbC52Mi5H",
            "ZXREZWZhdWx0QnJhbmNoUmVzcG9uc2UiUoLT5JMCQhJAL3YyL3tjYXRhbG9n",
            "PXByb2plY3RzLyovbG9jYXRpb25zLyovY2F0YWxvZ3MvKn06Z2V0RGVmYXVs",
            "dEJyYW5jaNpBB2NhdGFsb2caScpBFXJldGFpbC5nb29nbGVhcGlzLmNvbdJB",
            "Lmh0dHBzOi8vd3d3Lmdvb2dsZWFwaXMuY29tL2F1dGgvY2xvdWQtcGxhdGZv",
            "cm1CyAEKGmNvbS5nb29nbGUuY2xvdWQucmV0YWlsLnYyQhNDYXRhbG9nU2Vy",
            "dmljZVByb3RvUAFaPGdvb2dsZS5nb2xhbmcub3JnL2dlbnByb3RvL2dvb2ds",
            "ZWFwaXMvY2xvdWQvcmV0YWlsL3YyO3JldGFpbKICBlJFVEFJTKoCFkdvb2ds",
            "ZS5DbG91ZC5SZXRhaWwuVjLKAhZHb29nbGVcQ2xvdWRcUmV0YWlsXFYy6gIZ",
            "R29vZ2xlOjpDbG91ZDo6UmV0YWlsOjpWMmIGcHJvdG8z"));
      descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
          new pbr::FileDescriptor[] { global::Google.Api.AnnotationsReflection.Descriptor, global::Google.Api.ClientReflection.Descriptor, global::Google.Api.FieldBehaviorReflection.Descriptor, global::Google.Api.ResourceReflection.Descriptor, global::Google.Cloud.Retail.V2.CatalogReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.EmptyReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.FieldMaskReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.TimestampReflection.Descriptor, },
          new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
            new pbr::GeneratedClrTypeInfo(typeof(global::Google.Cloud.Retail.V2.ListCatalogsRequest), global::Google.Cloud.Retail.V2.ListCatalogsRequest.Parser, new[]{ "Parent", "PageSize", "PageToken" }, null, null, null, null),
            new pbr::GeneratedClrTypeInfo(typeof(global::Google.Cloud.Retail.V2.ListCatalogsResponse), global::Google.Cloud.Retail.V2.ListCatalogsResponse.Parser, new[]{ "Catalogs", "NextPageToken" }, null, null, null, null),
            new pbr::GeneratedClrTypeInfo(typeof(global::Google.Cloud.Retail.V2.UpdateCatalogRequest), global::Google.Cloud.Retail.V2.UpdateCatalogRequest.Parser, new[]{ "Catalog", "UpdateMask" }, null, null, null, null),
            new pbr::GeneratedClrTypeInfo(typeof(global::Google.Cloud.Retail.V2.SetDefaultBranchRequest), global::Google.Cloud.Retail.V2.SetDefaultBranchRequest.Parser, new[]{ "Catalog", "BranchId", "Note", "Force" }, null, null, null, null),
            new pbr::GeneratedClrTypeInfo(typeof(global::Google.Cloud.Retail.V2.GetDefaultBranchRequest), global::Google.Cloud.Retail.V2.GetDefaultBranchRequest.Parser, new[]{ "Catalog" }, null, null, null, null),
            new pbr::GeneratedClrTypeInfo(typeof(global::Google.Cloud.Retail.V2.GetDefaultBranchResponse), global::Google.Cloud.Retail.V2.GetDefaultBranchResponse.Parser, new[]{ "Branch", "SetTime", "Note" }, null, null, null, null)
          }));
    }
    #endregion

  }
  #region Messages
  ///
  /// Request for
  /// [CatalogService.ListCatalogs][google.cloud.retail.v2.CatalogService.ListCatalogs]
  /// method.
  ///
  public sealed partial class ListCatalogsRequest : pb::IMessage<ListCatalogsRequest>
  #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
      , pb::IBufferMessage
  #endif
  {
    private static readonly pb::MessageParser<ListCatalogsRequest> _parser = new pb::MessageParser<ListCatalogsRequest>(() => new ListCatalogsRequest());
    private pb::UnknownFieldSet _unknownFields;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public static pb::MessageParser<ListCatalogsRequest> Parser { get { return _parser; } }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public static pbr::MessageDescriptor Descriptor {
      get { return global::Google.Cloud.Retail.V2.CatalogServiceReflection.Descriptor.MessageTypes[0]; }
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    pbr::MessageDescriptor pb::IMessage.Descriptor {
      get { return Descriptor; }
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public ListCatalogsRequest() {
      OnConstruction();
    }

    partial void OnConstruction();

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public ListCatalogsRequest(ListCatalogsRequest other) : this() {
      parent_ = other.parent_;
      pageSize_ = other.pageSize_;
      pageToken_ = other.pageToken_;
      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public ListCatalogsRequest Clone() {
      return new ListCatalogsRequest(this);
    }

    /// Field number for the "parent" field.
    public const int ParentFieldNumber = 1;
    private string parent_ = "";
    ///
    /// Required. The account resource name with an associated location.
    ///
    /// If the caller does not have permission to list
    /// [Catalog][google.cloud.retail.v2.Catalog]s under this location, regardless
    /// of whether or not this location exists, a PERMISSION_DENIED error is
    /// returned.
    ///
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public string Parent {
      get { return parent_; }
      set {
        parent_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
      }
    }

    /// Field number for the "page_size" field.
    public const int PageSizeFieldNumber = 2;
    private int pageSize_;
    ///
    /// Maximum number of [Catalog][google.cloud.retail.v2.Catalog]s to return. If
    /// unspecified, defaults to 50. The maximum allowed value is 1000. Values
    /// above 1000 will be coerced to 1000.
    ///
    /// If this field is negative, an INVALID_ARGUMENT is returned.
    ///
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public int PageSize {
      get { return pageSize_; }
      set {
        pageSize_ = value;
      }
    }

    /// Field number for the "page_token" field.
    public const int PageTokenFieldNumber = 3;
    private string pageToken_ = "";
    ///
    /// A page token
    /// [ListCatalogsResponse.next_page_token][google.cloud.retail.v2.ListCatalogsResponse.next_page_token],
    /// received from a previous
    /// [CatalogService.ListCatalogs][google.cloud.retail.v2.CatalogService.ListCatalogs]
    /// call. Provide this to retrieve the subsequent page.
    ///
    /// When paginating, all other parameters provided to
    /// [CatalogService.ListCatalogs][google.cloud.retail.v2.CatalogService.ListCatalogs]
    /// must match the call that provided the page token. Otherwise, an
    /// INVALID_ARGUMENT error is returned.
    ///
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public string PageToken {
      get { return pageToken_; }
      set {
        pageToken_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
      }
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public override bool Equals(object other) {
      return Equals(other as ListCatalogsRequest);
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public bool Equals(ListCatalogsRequest other) {
      if (ReferenceEquals(other, null)) {
        return false;
      }
      if (ReferenceEquals(other, this)) {
        return true;
      }
      if (Parent != other.Parent) return false;
      if (PageSize != other.PageSize) return false;
      if (PageToken != other.PageToken) return false;
      return Equals(_unknownFields, other._unknownFields);
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public override int GetHashCode() {
      int hash = 1;
      if (Parent.Length != 0) hash ^= Parent.GetHashCode();
      if (PageSize != 0) hash ^= PageSize.GetHashCode();
      if (PageToken.Length != 0) hash ^= PageToken.GetHashCode();
      if (_unknownFields != null) {
        hash ^= _unknownFields.GetHashCode();
      }
      return hash;
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public override string ToString() {
      return pb::JsonFormatter.ToDiagnosticString(this);
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public void WriteTo(pb::CodedOutputStream output) {
    #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
      output.WriteRawMessage(this);
    #else
      if (Parent.Length != 0) {
        output.WriteRawTag(10);
        output.WriteString(Parent);
      }
      if (PageSize != 0) {
        output.WriteRawTag(16);
        output.WriteInt32(PageSize);
      }
      if (PageToken.Length != 0) {
        output.WriteRawTag(26);
        output.WriteString(PageToken);
      }
      if (_unknownFields != null) {
        _unknownFields.WriteTo(output);
      }
    #endif
    }

    #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) {
      if (Parent.Length != 0) {
        output.WriteRawTag(10);
        output.WriteString(Parent);
      }
      if (PageSize != 0) {
        output.WriteRawTag(16);
        output.WriteInt32(PageSize);
      }
      if (PageToken.Length != 0) {
        output.WriteRawTag(26);
        output.WriteString(PageToken);
      }
      if (_unknownFields != null) {
        _unknownFields.WriteTo(ref output);
      }
    }
    #endif

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public int CalculateSize() {
      int size = 0;
      if (Parent.Length != 0) {
        size += 1 + pb::CodedOutputStream.ComputeStringSize(Parent);
      }
      if (PageSize != 0) {
        size += 1 + pb::CodedOutputStream.ComputeInt32Size(PageSize);
      }
      if (PageToken.Length != 0) {
        size += 1 + pb::CodedOutputStream.ComputeStringSize(PageToken);
      }
      if (_unknownFields != null) {
        size += _unknownFields.CalculateSize();
      }
      return size;
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public void MergeFrom(ListCatalogsRequest other) {
      if (other == null) {
        return;
      }
      if (other.Parent.Length != 0) {
        Parent = other.Parent;
      }
      if (other.PageSize != 0) {
        PageSize = other.PageSize;
      }
      if (other.PageToken.Length != 0) {
        PageToken = other.PageToken;
      }
      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public void MergeFrom(pb::CodedInputStream input) {
    #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
      input.ReadRawMessage(this);
    #else
      uint tag;
      while ((tag = input.ReadTag()) != 0) {
        switch(tag) {
          default:
            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
            break;
          case 10: {
            Parent = input.ReadString();
            break;
          }
          case 16: {
            PageSize = input.ReadInt32();
            break;
          }
          case 26: {
            PageToken = input.ReadString();
            break;
          }
        }
      }
    #endif
    }

    #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) {
      uint tag;
      while ((tag = input.ReadTag()) != 0) {
        switch(tag) {
          default:
            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input);
            break;
          case 10: {
            Parent = input.ReadString();
            break;
          }
          case 16: {
            PageSize = input.ReadInt32();
            break;
          }
          case 26: {
            PageToken = input.ReadString();
            break;
          }
        }
      }
    }
    #endif

  }

  ///
  /// Response for
  /// [CatalogService.ListCatalogs][google.cloud.retail.v2.CatalogService.ListCatalogs]
  /// method.
  ///
  public sealed partial class ListCatalogsResponse : pb::IMessage<ListCatalogsResponse>
  #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
      , pb::IBufferMessage
  #endif
  {
    private static readonly pb::MessageParser<ListCatalogsResponse> _parser = new pb::MessageParser<ListCatalogsResponse>(() => new ListCatalogsResponse());
    private pb::UnknownFieldSet _unknownFields;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public static pb::MessageParser<ListCatalogsResponse> Parser { get { return _parser; } }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public static pbr::MessageDescriptor Descriptor {
      get { return global::Google.Cloud.Retail.V2.CatalogServiceReflection.Descriptor.MessageTypes[1]; }
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    pbr::MessageDescriptor pb::IMessage.Descriptor {
      get { return Descriptor; }
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public ListCatalogsResponse() {
      OnConstruction();
    }

    partial void OnConstruction();

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public ListCatalogsResponse(ListCatalogsResponse other) : this() {
      catalogs_ = other.catalogs_.Clone();
      nextPageToken_ = other.nextPageToken_;
      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public ListCatalogsResponse Clone() {
      return new ListCatalogsResponse(this);
    }

    /// Field number for the "catalogs" field.
    public const int CatalogsFieldNumber = 1;
    private static readonly pb::FieldCodec<global::Google.Cloud.Retail.V2.Catalog> _repeated_catalogs_codec
        = pb::FieldCodec.ForMessage(10, global::Google.Cloud.Retail.V2.Catalog.Parser);
    private readonly pbc::RepeatedField<global::Google.Cloud.Retail.V2.Catalog> catalogs_ = new pbc::RepeatedField<global::Google.Cloud.Retail.V2.Catalog>();
    ///
    /// All the customer's [Catalog][google.cloud.retail.v2.Catalog]s.
    ///
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public pbc::RepeatedField<global::Google.Cloud.Retail.V2.Catalog> Catalogs {
      get { return catalogs_; }
    }

    /// Field number for the "next_page_token" field.
    public const int NextPageTokenFieldNumber = 2;
    private string nextPageToken_ = "";
    ///
    /// A token that can be sent as
    /// [ListCatalogsRequest.page_token][google.cloud.retail.v2.ListCatalogsRequest.page_token]
    /// to retrieve the next page. If this field is omitted, there are no
    /// subsequent pages.
    ///
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public string NextPageToken {
      get { return nextPageToken_; }
      set {
        nextPageToken_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
      }
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public override bool Equals(object other) {
      return Equals(other as ListCatalogsResponse);
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public bool Equals(ListCatalogsResponse other) {
      if (ReferenceEquals(other, null)) {
        return false;
      }
      if (ReferenceEquals(other, this)) {
        return true;
      }
      if(!catalogs_.Equals(other.catalogs_)) return false;
      if (NextPageToken != other.NextPageToken) return false;
      return Equals(_unknownFields, other._unknownFields);
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public override int GetHashCode() {
      int hash = 1;
      hash ^= catalogs_.GetHashCode();
      if (NextPageToken.Length != 0) hash ^= NextPageToken.GetHashCode();
      if (_unknownFields != null) {
        hash ^= _unknownFields.GetHashCode();
      }
      return hash;
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public override string ToString() {
      return pb::JsonFormatter.ToDiagnosticString(this);
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public void WriteTo(pb::CodedOutputStream output) {
    #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
      output.WriteRawMessage(this);
    #else
      catalogs_.WriteTo(output, _repeated_catalogs_codec);
      if (NextPageToken.Length != 0) {
        output.WriteRawTag(18);
        output.WriteString(NextPageToken);
      }
      if (_unknownFields != null) {
        _unknownFields.WriteTo(output);
      }
    #endif
    }

    #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) {
      catalogs_.WriteTo(ref output, _repeated_catalogs_codec);
      if (NextPageToken.Length != 0) {
        output.WriteRawTag(18);
        output.WriteString(NextPageToken);
      }
      if (_unknownFields != null) {
        _unknownFields.WriteTo(ref output);
      }
    }
    #endif

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public int CalculateSize() {
      int size = 0;
      size += catalogs_.CalculateSize(_repeated_catalogs_codec);
      if (NextPageToken.Length != 0) {
        size += 1 + pb::CodedOutputStream.ComputeStringSize(NextPageToken);
      }
      if (_unknownFields != null) {
        size += _unknownFields.CalculateSize();
      }
      return size;
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public void MergeFrom(ListCatalogsResponse other) {
      if (other == null) {
        return;
      }
      catalogs_.Add(other.catalogs_);
      if (other.NextPageToken.Length != 0) {
        NextPageToken = other.NextPageToken;
      }
      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public void MergeFrom(pb::CodedInputStream input) {
    #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
      input.ReadRawMessage(this);
    #else
      uint tag;
      while ((tag = input.ReadTag()) != 0) {
        switch(tag) {
          default:
            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
            break;
          case 10: {
            catalogs_.AddEntriesFrom(input, _repeated_catalogs_codec);
            break;
          }
          case 18: {
            NextPageToken = input.ReadString();
            break;
          }
        }
      }
    #endif
    }

    #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) {
      uint tag;
      while ((tag = input.ReadTag()) != 0) {
        switch(tag) {
          default:
            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input);
            break;
          case 10: {
            catalogs_.AddEntriesFrom(ref input, _repeated_catalogs_codec);
            break;
          }
          case 18: {
            NextPageToken = input.ReadString();
            break;
          }
        }
      }
    }
    #endif

  }

  ///
  /// Request for
  /// [CatalogService.UpdateCatalog][google.cloud.retail.v2.CatalogService.UpdateCatalog]
  /// method.
  ///
  public sealed partial class UpdateCatalogRequest : pb::IMessage<UpdateCatalogRequest>
  #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
      , pb::IBufferMessage
  #endif
  {
    private static readonly pb::MessageParser<UpdateCatalogRequest> _parser = new pb::MessageParser<UpdateCatalogRequest>(() => new UpdateCatalogRequest());
    private pb::UnknownFieldSet _unknownFields;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public static pb::MessageParser<UpdateCatalogRequest> Parser { get { return _parser; } }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public static pbr::MessageDescriptor Descriptor {
      get { return global::Google.Cloud.Retail.V2.CatalogServiceReflection.Descriptor.MessageTypes[2]; }
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    pbr::MessageDescriptor pb::IMessage.Descriptor {
      get { return Descriptor; }
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public UpdateCatalogRequest() {
      OnConstruction();
    }

    partial void OnConstruction();

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public UpdateCatalogRequest(UpdateCatalogRequest other) : this() {
      catalog_ = other.catalog_ != null ? other.catalog_.Clone() : null;
      updateMask_ = other.updateMask_ != null ? other.updateMask_.Clone() : null;
      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public UpdateCatalogRequest Clone() {
      return new UpdateCatalogRequest(this);
    }

    /// Field number for the "catalog" field.
    public const int CatalogFieldNumber = 1;
    private global::Google.Cloud.Retail.V2.Catalog catalog_;
    ///
    /// Required. The [Catalog][google.cloud.retail.v2.Catalog] to update.
    ///
    /// If the caller does not have permission to update the
    /// [Catalog][google.cloud.retail.v2.Catalog], regardless of whether or not it
    /// exists, a PERMISSION_DENIED error is returned.
    ///
    /// If the [Catalog][google.cloud.retail.v2.Catalog] to update does not exist,
    /// a NOT_FOUND error is returned.
    ///
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public global::Google.Cloud.Retail.V2.Catalog Catalog {
      get { return catalog_; }
      set {
        catalog_ = value;
      }
    }

    /// Field number for the "update_mask" field.
    public const int UpdateMaskFieldNumber = 2;
    private global::Google.Protobuf.WellKnownTypes.FieldMask updateMask_;
    ///
    /// Indicates which fields in the provided
    /// [Catalog][google.cloud.retail.v2.Catalog] to update.
    ///
    /// If an unsupported or unknown field is provided, an INVALID_ARGUMENT error
    /// is returned.
    ///
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public global::Google.Protobuf.WellKnownTypes.FieldMask UpdateMask {
      get { return updateMask_; }
      set {
        updateMask_ = value;
      }
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public override bool Equals(object other) {
      return Equals(other as UpdateCatalogRequest);
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public bool Equals(UpdateCatalogRequest other) {
      if (ReferenceEquals(other, null)) {
        return false;
      }
      if (ReferenceEquals(other, this)) {
        return true;
      }
      if (!object.Equals(Catalog, other.Catalog)) return false;
      if (!object.Equals(UpdateMask, other.UpdateMask)) return false;
      return Equals(_unknownFields, other._unknownFields);
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public override int GetHashCode() {
      int hash = 1;
      if (catalog_ != null) hash ^= Catalog.GetHashCode();
      if (updateMask_ != null) hash ^= UpdateMask.GetHashCode();
      if (_unknownFields != null) {
        hash ^= _unknownFields.GetHashCode();
      }
      return hash;
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public override string ToString() {
      return pb::JsonFormatter.ToDiagnosticString(this);
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public void WriteTo(pb::CodedOutputStream output) {
    #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
      output.WriteRawMessage(this);
    #else
      if (catalog_ != null) {
        output.WriteRawTag(10);
        output.WriteMessage(Catalog);
      }
      if (updateMask_ != null) {
        output.WriteRawTag(18);
        output.WriteMessage(UpdateMask);
      }
      if (_unknownFields != null) {
        _unknownFields.WriteTo(output);
      }
    #endif
    }

    #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) {
      if (catalog_ != null) {
        output.WriteRawTag(10);
        output.WriteMessage(Catalog);
      }
      if (updateMask_ != null) {
        output.WriteRawTag(18);
        output.WriteMessage(UpdateMask);
      }
      if (_unknownFields != null) {
        _unknownFields.WriteTo(ref output);
      }
    }
    #endif

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public int CalculateSize() {
      int size = 0;
      if (catalog_ != null) {
        size += 1 + pb::CodedOutputStream.ComputeMessageSize(Catalog);
      }
      if (updateMask_ != null) {
        size += 1 + pb::CodedOutputStream.ComputeMessageSize(UpdateMask);
      }
      if (_unknownFields != null) {
        size += _unknownFields.CalculateSize();
      }
      return size;
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public void MergeFrom(UpdateCatalogRequest other) {
      if (other == null) {
        return;
      }
      if (other.catalog_ != null) {
        if (catalog_ == null) {
          Catalog = new global::Google.Cloud.Retail.V2.Catalog();
        }
        Catalog.MergeFrom(other.Catalog);
      }
      if (other.updateMask_ != null) {
        if (updateMask_ == null) {
          UpdateMask = new global::Google.Protobuf.WellKnownTypes.FieldMask();
        }
        UpdateMask.MergeFrom(other.UpdateMask);
      }
      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public void MergeFrom(pb::CodedInputStream input) {
    #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
      input.ReadRawMessage(this);
    #else
      uint tag;
      while ((tag = input.ReadTag()) != 0) {
        switch(tag) {
          default:
            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
            break;
          case 10: {
            if (catalog_ == null) {
              Catalog = new global::Google.Cloud.Retail.V2.Catalog();
            }
            input.ReadMessage(Catalog);
            break;
          }
          case 18: {
            if (updateMask_ == null) {
              UpdateMask = new global::Google.Protobuf.WellKnownTypes.FieldMask();
            }
            input.ReadMessage(UpdateMask);
            break;
          }
        }
      }
    #endif
    }

    #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) {
      uint tag;
      while ((tag = input.ReadTag()) != 0) {
        switch(tag) {
          default:
            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input);
            break;
          case 10: {
            if (catalog_ == null) {
              Catalog = new global::Google.Cloud.Retail.V2.Catalog();
            }
            input.ReadMessage(Catalog);
            break;
          }
          case 18: {
            if (updateMask_ == null) {
              UpdateMask = new global::Google.Protobuf.WellKnownTypes.FieldMask();
            }
            input.ReadMessage(UpdateMask);
            break;
          }
        }
      }
    }
    #endif

  }

  ///
  /// Request message to set a specified branch as new default_branch.
  ///
  public sealed partial class SetDefaultBranchRequest : pb::IMessage<SetDefaultBranchRequest>
  #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
      , pb::IBufferMessage
  #endif
  {
    private static readonly pb::MessageParser<SetDefaultBranchRequest> _parser = new pb::MessageParser<SetDefaultBranchRequest>(() => new SetDefaultBranchRequest());
    private pb::UnknownFieldSet _unknownFields;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public static pb::MessageParser<SetDefaultBranchRequest> Parser { get { return _parser; } }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public static pbr::MessageDescriptor Descriptor {
      get { return global::Google.Cloud.Retail.V2.CatalogServiceReflection.Descriptor.MessageTypes[3]; }
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    pbr::MessageDescriptor pb::IMessage.Descriptor {
      get { return Descriptor; }
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public SetDefaultBranchRequest() {
      OnConstruction();
    }

    partial void OnConstruction();

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public SetDefaultBranchRequest(SetDefaultBranchRequest other) : this() {
      catalog_ = other.catalog_;
      branchId_ = other.branchId_;
      note_ = other.note_;
      force_ = other.force_;
      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public SetDefaultBranchRequest Clone() {
      return new SetDefaultBranchRequest(this);
    }

    /// Field number for the "catalog" field.
    public const int CatalogFieldNumber = 1;
    private string catalog_ = "";
    ///
    /// Full resource name of the catalog, such as
    /// `projects/*/locations/global/catalogs/default_catalog`.
    ///
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public string Catalog {
      get { return catalog_; }
      set {
        catalog_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
      }
    }

    /// Field number for the "branch_id" field.
    public const int BranchIdFieldNumber = 2;
    private string branchId_ = "";
    ///
    /// The final component of the resource name of a branch.
    ///
    /// This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT
    /// error is returned.
    ///
    /// If there are no sufficient active products in the targeted branch and
    /// [force][google.cloud.retail.v2.SetDefaultBranchRequest.force] is not set, a
    /// FAILED_PRECONDITION error is returned.
    ///
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public string BranchId {
      get { return branchId_; }
      set {
        branchId_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
      }
    }

    /// Field number for the "note" field.
    public const int NoteFieldNumber = 3;
    private string note_ = "";
    ///
    /// Some note on this request, this can be retrieved by
    /// [CatalogService.GetDefaultBranch][google.cloud.retail.v2.CatalogService.GetDefaultBranch]
    /// before next valid default branch set occurs.
    ///
    /// This field must be a UTF-8 encoded string with a length limit of 1,000
    /// characters. Otherwise, an INVALID_ARGUMENT error is returned.
    ///
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public string Note {
      get { return note_; }
      set {
        note_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
      }
    }

    /// Field number for the "force" field.
    public const int ForceFieldNumber = 4;
    private bool force_;
    ///
    /// If set to true, it permits switching to a branch with
    /// [branch_id][google.cloud.retail.v2.SetDefaultBranchRequest.branch_id] even
    /// if it has no sufficient active products.
    ///
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public bool Force {
      get { return force_; }
      set {
        force_ = value;
      }
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public override bool Equals(object other) {
      return Equals(other as SetDefaultBranchRequest);
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public bool Equals(SetDefaultBranchRequest other) {
      if (ReferenceEquals(other, null)) {
        return false;
      }
      if (ReferenceEquals(other, this)) {
        return true;
      }
      if (Catalog != other.Catalog) return false;
      if (BranchId != other.BranchId) return false;
      if (Note != other.Note) return false;
      if (Force != other.Force) return false;
      return Equals(_unknownFields, other._unknownFields);
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public override int GetHashCode() {
      int hash = 1;
      if (Catalog.Length != 0) hash ^= Catalog.GetHashCode();
      if (BranchId.Length != 0) hash ^= BranchId.GetHashCode();
      if (Note.Length != 0) hash ^= Note.GetHashCode();
      if (Force != false) hash ^= Force.GetHashCode();
      if (_unknownFields != null) {
        hash ^= _unknownFields.GetHashCode();
      }
      return hash;
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public override string ToString() {
      return pb::JsonFormatter.ToDiagnosticString(this);
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public void WriteTo(pb::CodedOutputStream output) {
    #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
      output.WriteRawMessage(this);
    #else
      if (Catalog.Length != 0) {
        output.WriteRawTag(10);
        output.WriteString(Catalog);
      }
      if (BranchId.Length != 0) {
        output.WriteRawTag(18);
        output.WriteString(BranchId);
      }
      if (Note.Length != 0) {
        output.WriteRawTag(26);
        output.WriteString(Note);
      }
      if (Force != false) {
        output.WriteRawTag(32);
        output.WriteBool(Force);
      }
      if (_unknownFields != null) {
        _unknownFields.WriteTo(output);
      }
    #endif
    }

    #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) {
      if (Catalog.Length != 0) {
        output.WriteRawTag(10);
        output.WriteString(Catalog);
      }
      if (BranchId.Length != 0) {
        output.WriteRawTag(18);
        output.WriteString(BranchId);
      }
      if (Note.Length != 0) {
        output.WriteRawTag(26);
        output.WriteString(Note);
      }
      if (Force != false) {
        output.WriteRawTag(32);
        output.WriteBool(Force);
      }
      if (_unknownFields != null) {
        _unknownFields.WriteTo(ref output);
      }
    }
    #endif

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public int CalculateSize() {
      int size = 0;
      if (Catalog.Length != 0) {
        size += 1 + pb::CodedOutputStream.ComputeStringSize(Catalog);
      }
      if (BranchId.Length != 0) {
        size += 1 + pb::CodedOutputStream.ComputeStringSize(BranchId);
      }
      if (Note.Length != 0) {
        size += 1 + pb::CodedOutputStream.ComputeStringSize(Note);
      }
      if (Force != false) {
        size += 1 + 1;
      }
      if (_unknownFields != null) {
        size += _unknownFields.CalculateSize();
      }
      return size;
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public void MergeFrom(SetDefaultBranchRequest other) {
      if (other == null) {
        return;
      }
      if (other.Catalog.Length != 0) {
        Catalog = other.Catalog;
      }
      if (other.BranchId.Length != 0) {
        BranchId = other.BranchId;
      }
      if (other.Note.Length != 0) {
        Note = other.Note;
      }
      if (other.Force != false) {
        Force = other.Force;
      }
      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public void MergeFrom(pb::CodedInputStream input) {
    #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
      input.ReadRawMessage(this);
    #else
      uint tag;
      while ((tag = input.ReadTag()) != 0) {
        switch(tag) {
          default:
            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
            break;
          case 10: {
            Catalog = input.ReadString();
            break;
          }
          case 18: {
            BranchId = input.ReadString();
            break;
          }
          case 26: {
            Note = input.ReadString();
            break;
          }
          case 32: {
            Force = input.ReadBool();
            break;
          }
        }
      }
    #endif
    }

    #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) {
      uint tag;
      while ((tag = input.ReadTag()) != 0) {
        switch(tag) {
          default:
            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input);
            break;
          case 10: {
            Catalog = input.ReadString();
            break;
          }
          case 18: {
            BranchId = input.ReadString();
            break;
          }
          case 26: {
            Note = input.ReadString();
            break;
          }
          case 32: {
            Force = input.ReadBool();
            break;
          }
        }
      }
    }
    #endif

  }

  ///
  /// Request message to show which branch is currently the default branch.
  ///
  public sealed partial class GetDefaultBranchRequest : pb::IMessage<GetDefaultBranchRequest>
  #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
      , pb::IBufferMessage
  #endif
  {
    private static readonly pb::MessageParser<GetDefaultBranchRequest> _parser = new pb::MessageParser<GetDefaultBranchRequest>(() => new GetDefaultBranchRequest());
    private pb::UnknownFieldSet _unknownFields;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public static pb::MessageParser<GetDefaultBranchRequest> Parser { get { return _parser; } }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public static pbr::MessageDescriptor Descriptor {
      get { return global::Google.Cloud.Retail.V2.CatalogServiceReflection.Descriptor.MessageTypes[4]; }
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    pbr::MessageDescriptor pb::IMessage.Descriptor {
      get { return Descriptor; }
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public GetDefaultBranchRequest() {
      OnConstruction();
    }

    partial void OnConstruction();

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public GetDefaultBranchRequest(GetDefaultBranchRequest other) : this() {
      catalog_ = other.catalog_;
      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public GetDefaultBranchRequest Clone() {
      return new GetDefaultBranchRequest(this);
    }

    /// Field number for the "catalog" field.
    public const int CatalogFieldNumber = 1;
    private string catalog_ = "";
    ///
    /// The parent catalog resource name, such as
    /// `projects/*/locations/global/catalogs/default_catalog`.
    ///
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public string Catalog {
      get { return catalog_; }
      set {
        catalog_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
      }
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public override bool Equals(object other) {
      return Equals(other as GetDefaultBranchRequest);
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public bool Equals(GetDefaultBranchRequest other) {
      if (ReferenceEquals(other, null)) {
        return false;
      }
      if (ReferenceEquals(other, this)) {
        return true;
      }
      if (Catalog != other.Catalog) return false;
      return Equals(_unknownFields, other._unknownFields);
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public override int GetHashCode() {
      int hash = 1;
      if (Catalog.Length != 0) hash ^= Catalog.GetHashCode();
      if (_unknownFields != null) {
        hash ^= _unknownFields.GetHashCode();
      }
      return hash;
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public override string ToString() {
      return pb::JsonFormatter.ToDiagnosticString(this);
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public void WriteTo(pb::CodedOutputStream output) {
    #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
      output.WriteRawMessage(this);
    #else
      if (Catalog.Length != 0) {
        output.WriteRawTag(10);
        output.WriteString(Catalog);
      }
      if (_unknownFields != null) {
        _unknownFields.WriteTo(output);
      }
    #endif
    }

    #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) {
      if (Catalog.Length != 0) {
        output.WriteRawTag(10);
        output.WriteString(Catalog);
      }
      if (_unknownFields != null) {
        _unknownFields.WriteTo(ref output);
      }
    }
    #endif

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public int CalculateSize() {
      int size = 0;
      if (Catalog.Length != 0) {
        size += 1 + pb::CodedOutputStream.ComputeStringSize(Catalog);
      }
      if (_unknownFields != null) {
        size += _unknownFields.CalculateSize();
      }
      return size;
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public void MergeFrom(GetDefaultBranchRequest other) {
      if (other == null) {
        return;
      }
      if (other.Catalog.Length != 0) {
        Catalog = other.Catalog;
      }
      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public void MergeFrom(pb::CodedInputStream input) {
    #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
      input.ReadRawMessage(this);
    #else
      uint tag;
      while ((tag = input.ReadTag()) != 0) {
        switch(tag) {
          default:
            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
            break;
          case 10: {
            Catalog = input.ReadString();
            break;
          }
        }
      }
    #endif
    }

    #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) {
      uint tag;
      while ((tag = input.ReadTag()) != 0) {
        switch(tag) {
          default:
            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input);
            break;
          case 10: {
            Catalog = input.ReadString();
            break;
          }
        }
      }
    }
    #endif

  }

  ///
  /// Response message of
  /// [CatalogService.GetDefaultBranch][google.cloud.retail.v2.CatalogService.GetDefaultBranch].
  ///
  public sealed partial class GetDefaultBranchResponse : pb::IMessage<GetDefaultBranchResponse>
  #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
      , pb::IBufferMessage
  #endif
  {
    private static readonly pb::MessageParser<GetDefaultBranchResponse> _parser = new pb::MessageParser<GetDefaultBranchResponse>(() => new GetDefaultBranchResponse());
    private pb::UnknownFieldSet _unknownFields;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public static pb::MessageParser<GetDefaultBranchResponse> Parser { get { return _parser; } }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public static pbr::MessageDescriptor Descriptor {
      get { return global::Google.Cloud.Retail.V2.CatalogServiceReflection.Descriptor.MessageTypes[5]; }
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    pbr::MessageDescriptor pb::IMessage.Descriptor {
      get { return Descriptor; }
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public GetDefaultBranchResponse() {
      OnConstruction();
    }

    partial void OnConstruction();

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public GetDefaultBranchResponse(GetDefaultBranchResponse other) : this() {
      branch_ = other.branch_;
      setTime_ = other.setTime_ != null ? other.setTime_.Clone() : null;
      note_ = other.note_;
      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public GetDefaultBranchResponse Clone() {
      return new GetDefaultBranchResponse(this);
    }

    /// Field number for the "branch" field.
    public const int BranchFieldNumber = 1;
    private string branch_ = "";
    ///
    /// Full resource name of the branch id currently set as default branch.
    ///
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public string Branch {
      get { return branch_; }
      set {
        branch_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
      }
    }

    /// Field number for the "set_time" field.
    public const int SetTimeFieldNumber = 2;
    private global::Google.Protobuf.WellKnownTypes.Timestamp setTime_;
    ///
    /// The time when this branch is set to default.
    ///
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public global::Google.Protobuf.WellKnownTypes.Timestamp SetTime {
      get { return setTime_; }
      set {
        setTime_ = value;
      }
    }

    /// Field number for the "note" field.
    public const int NoteFieldNumber = 3;
    private string note_ = "";
    ///
    /// This corresponds to
    /// [SetDefaultBranchRequest.note][google.cloud.retail.v2.SetDefaultBranchRequest.note]
    /// field, when this branch was set as default.
    ///
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public string Note {
      get { return note_; }
      set {
        note_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
      }
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public override bool Equals(object other) {
      return Equals(other as GetDefaultBranchResponse);
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public bool Equals(GetDefaultBranchResponse other) {
      if (ReferenceEquals(other, null)) {
        return false;
      }
      if (ReferenceEquals(other, this)) {
        return true;
      }
      if (Branch != other.Branch) return false;
      if (!object.Equals(SetTime, other.SetTime)) return false;
      if (Note != other.Note) return false;
      return Equals(_unknownFields, other._unknownFields);
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public override int GetHashCode() {
      int hash = 1;
      if (Branch.Length != 0) hash ^= Branch.GetHashCode();
      if (setTime_ != null) hash ^= SetTime.GetHashCode();
      if (Note.Length != 0) hash ^= Note.GetHashCode();
      if (_unknownFields != null) {
        hash ^= _unknownFields.GetHashCode();
      }
      return hash;
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public override string ToString() {
      return pb::JsonFormatter.ToDiagnosticString(this);
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public void WriteTo(pb::CodedOutputStream output) {
    #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
      output.WriteRawMessage(this);
    #else
      if (Branch.Length != 0) {
        output.WriteRawTag(10);
        output.WriteString(Branch);
      }
      if (setTime_ != null) {
        output.WriteRawTag(18);
        output.WriteMessage(SetTime);
      }
      if (Note.Length != 0) {
        output.WriteRawTag(26);
        output.WriteString(Note);
      }
      if (_unknownFields != null) {
        _unknownFields.WriteTo(output);
      }
    #endif
    }

    #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) {
      if (Branch.Length != 0) {
        output.WriteRawTag(10);
        output.WriteString(Branch);
      }
      if (setTime_ != null) {
        output.WriteRawTag(18);
        output.WriteMessage(SetTime);
      }
      if (Note.Length != 0) {
        output.WriteRawTag(26);
        output.WriteString(Note);
      }
      if (_unknownFields != null) {
        _unknownFields.WriteTo(ref output);
      }
    }
    #endif

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public int CalculateSize() {
      int size = 0;
      if (Branch.Length != 0) {
        size += 1 + pb::CodedOutputStream.ComputeStringSize(Branch);
      }
      if (setTime_ != null) {
        size += 1 + pb::CodedOutputStream.ComputeMessageSize(SetTime);
      }
      if (Note.Length != 0) {
        size += 1 + pb::CodedOutputStream.ComputeStringSize(Note);
      }
      if (_unknownFields != null) {
        size += _unknownFields.CalculateSize();
      }
      return size;
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public void MergeFrom(GetDefaultBranchResponse other) {
      if (other == null) {
        return;
      }
      if (other.Branch.Length != 0) {
        Branch = other.Branch;
      }
      if (other.setTime_ != null) {
        if (setTime_ == null) {
          SetTime = new global::Google.Protobuf.WellKnownTypes.Timestamp();
        }
        SetTime.MergeFrom(other.SetTime);
      }
      if (other.Note.Length != 0) {
        Note = other.Note;
      }
      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    public void MergeFrom(pb::CodedInputStream input) {
    #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
      input.ReadRawMessage(this);
    #else
      uint tag;
      while ((tag = input.ReadTag()) != 0) {
        switch(tag) {
          default:
            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
            break;
          case 10: {
            Branch = input.ReadString();
            break;
          }
          case 18: {
            if (setTime_ == null) {
              SetTime = new global::Google.Protobuf.WellKnownTypes.Timestamp();
            }
            input.ReadMessage(SetTime);
            break;
          }
          case 26: {
            Note = input.ReadString();
            break;
          }
        }
      }
    #endif
    }

    #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
    void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) {
      uint tag;
      while ((tag = input.ReadTag()) != 0) {
        switch(tag) {
          default:
            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input);
            break;
          case 10: {
            Branch = input.ReadString();
            break;
          }
          case 18: {
            if (setTime_ == null) {
              SetTime = new global::Google.Protobuf.WellKnownTypes.Timestamp();
            }
            input.ReadMessage(SetTime);
            break;
          }
          case 26: {
            Note = input.ReadString();
            break;
          }
        }
      }
    }
    #endif

  }

  #endregion

}

#endregion Designer generated code


text:
// Copyright 2015 The Closure Library Authors. All Rights Reserved.
//
// 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
//
//      http://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.

goog.provide('goog.net.FetchXmlHttp');
goog.provide('goog.net.FetchXmlHttpFactory');

goog.require('goog.asserts');
goog.require('goog.events.EventTarget');
goog.require('goog.functions');
goog.require('goog.log');
goog.require('goog.net.XhrLike');
goog.require('goog.net.XmlHttpFactory');

/**
 * Factory for creating Xhr objects that uses the native fetch() method.
 * https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
 * Note that this factory is intended for use in Service Worker only.
 * @param {!WorkerGlobalScope} worker The Service Worker global scope.
 * @extends {goog.net.XmlHttpFactory}
 * @struct
 * @constructor
 */
goog.net.FetchXmlHttpFactory = function(worker) {
  goog.net.FetchXmlHttpFactory.base(this, 'constructor');

  /** @private @final {!WorkerGlobalScope} */
  this.worker_ = worker;

  /** @private {!RequestCredentials|undefined} */
  this.credentialsMode_ = undefined;

  /** @private {!RequestCache|undefined} */
  this.cacheMode_ = undefined;
};
goog.inherits(goog.net.FetchXmlHttpFactory, goog.net.XmlHttpFactory);

/** @override */
goog.net.FetchXmlHttpFactory.prototype.createInstance = function() {
  var instance = new goog.net.FetchXmlHttp(this.worker_);
  if (this.credentialsMode_) {
    instance.setCredentialsMode(this.credentialsMode_);
  }
  if (this.cacheMode_) {
    instance.setCacheMode(this.cacheMode_);
  }
  return instance;
};

/** @override */
goog.net.FetchXmlHttpFactory.prototype.internalGetOptions =
    goog.functions.constant({});

/**
 * @param {!RequestCredentials} credentialsMode The credentials mode of the
 *     Service Worker fetch.
 */
goog.net.FetchXmlHttpFactory.prototype.setCredentialsMode = function(
    credentialsMode) {
  this.credentialsMode_ = credentialsMode;
};

/**
 * @param {!RequestCache} cacheMode The cache mode of the Service Worker fetch.
 */
goog.net.FetchXmlHttpFactory.prototype.setCacheMode = function(cacheMode) {
  this.cacheMode_ = cacheMode;
};

/**
 * FetchXmlHttp object constructor.
 * @param {!WorkerGlobalScope} worker
 * @extends {goog.events.EventTarget}
 * @implements {goog.net.XhrLike}
 * @constructor
 * @struct
 */
goog.net.FetchXmlHttp = function(worker) {
  goog.net.FetchXmlHttp.base(this, 'constructor');

  /** @private @final {!WorkerGlobalScope} */
  this.worker_ = worker;

  /** @private {RequestCredentials|undefined} */
  this.credentialsMode_ = undefined;

  /** @private {RequestCache|undefined} */
  this.cacheMode_ = undefined;

  /**
   * Request state.
   * @type {goog.net.FetchXmlHttp.RequestState}
   */
  this.readyState = goog.net.FetchXmlHttp.RequestState.UNSENT;

  /**
   * HTTP status.
   * @type {number}
   */
  this.status = 0;

  /**
   * HTTP status string.
   * @type {string}
   */
  this.statusText = '';

  /**
   * Content of the response.
   * @type {string}
   */
  this.responseText = '';

  /**
   * Document response entity body.
   * NOTE: This is always null and not supported by this class.
   * @final {null}
   */
  this.responseXML = null;

  /**
   * Method to call when the state changes.
   * @type {?function()}
   */
  this.onreadystatechange = null;

  /** @private {!Headers} */
  this.requestHeaders_ = new Headers();

  /** @private {?Headers} */
  this.responseHeaders_ = null;

  /**
   * Request method (GET or POST).
   * @private {string}
   */
  this.method_ = 'GET';

  /**
   * Request URL.
   * @private {string}
   */
  this.url_ = '';

  /**
   * Whether the request is in progress.
   * @private {boolean}
   */
  this.inProgress_ = false;

  /** @private @final {?goog.log.Logger} */
  this.logger_ = goog.log.getLogger('goog.net.FetchXmlHttp');

};
goog.inherits(goog.net.FetchXmlHttp, goog.events.EventTarget);

/**
 * State of the requests.
 * @enum {number}
 */
goog.net.FetchXmlHttp.RequestState = {
  UNSENT: 0,
  OPENED: 1,
  HEADER_RECEIVED: 2,
  LOADING: 3,
  DONE: 4
};

/** @override */
goog.net.FetchXmlHttp.prototype.open = function(method, url, opt_async) {
  goog.asserts.assert(!!opt_async, 'Only async requests are supported.');
  if (this.readyState != goog.net.FetchXmlHttp.RequestState.UNSENT) {
    this.abort();
    throw Error('Error reopening a connection');
  }

  this.method_ = method;
  this.url_ = url;

  this.readyState = goog.net.FetchXmlHttp.RequestState.OPENED;
  this.dispatchCallback_();
};

/** @override */
goog.net.FetchXmlHttp.prototype.send = function(opt_data) {
  if (this.readyState != goog.net.FetchXmlHttp.RequestState.OPENED) {
    this.abort();
    throw Error('need to call open() first. ');
  }

  this.inProgress_ = true;
  var requestInit = {
    headers: this.requestHeaders_,
    method: this.method_,
    credentials: this.credentialsMode_,
    cache: this.cacheMode_
  };
  if (opt_data) {
    requestInit['body'] = opt_data;
  }
  this.worker_
      .fetch(new Request(this.url_, /** @type {!RequestInit} */ (requestInit)))
      .then(
          this.handleResponse_.bind(this), this.handleSendFailure_.bind(this));
};

/** @override */
goog.net.FetchXmlHttp.prototype.abort = function() {
  this.responseText = '';
  this.requestHeaders_ = new Headers();
  this.status = 0;
  if (((this.readyState >= goog.net.FetchXmlHttp.RequestState.OPENED) &&
       this.inProgress_) &&
      (this.readyState != goog.net.FetchXmlHttp.RequestState.DONE)) {
    this.readyState = goog.net.FetchXmlHttp.RequestState.DONE;
    this.inProgress_ = false;
    this.dispatchCallback_();
  }

  this.readyState = goog.net.FetchXmlHttp.RequestState.UNSENT;
};

/**
 * Handles the fetch response.
 * @param {!Response} response
 * @private
 */
goog.net.FetchXmlHttp.prototype.handleResponse_ = function(response) {
  if (!this.inProgress_) {
    // The request was aborted, ignore.
    return;
  }

  if (!this.responseHeaders_) {
    this.responseHeaders_ = response.headers;
    this.readyState = goog.net.FetchXmlHttp.RequestState.HEADER_RECEIVED;
    this.dispatchCallback_();
  }
  // A callback may abort the request.
  if (!this.inProgress_) {
    // The request was aborted, ignore.
    return;
  }

  this.readyState = goog.net.FetchXmlHttp.RequestState.LOADING;
  this.dispatchCallback_();
  // A callback may abort the request.
  if (!this.inProgress_) {
    // The request was aborted, ignore.
    return;
  }
  response.text().then(
      this.handleResponseText_.bind(this, response),
      this.handleSendFailure_.bind(this));
};

/**
 * Handles the response text.
 * @param {!Response} response
 * @param {string} responseText
 * @private
 */
goog.net.FetchXmlHttp.prototype.handleResponseText_ = function(
    response, responseText) {
  if (!this.inProgress_) {
    // The request was aborted, ignore.
    return;
  }
  this.status = response.status;
  this.statusText = response.statusText;
  this.responseText = responseText;
  this.readyState = goog.net.FetchXmlHttp.RequestState.DONE;
  this.dispatchCallback_();
};

/**
 * Handles the send failure.
 * @param {*} error
 * @private
 */
goog.net.FetchXmlHttp.prototype.handleSendFailure_ = function(error) {
  var e = error instanceof Error ? error : Error(error);
  goog.log.warning(this.logger_, 'Failed to fetch url ' + this.url_, e);
  if (!this.inProgress_) {
    // The request was aborted, ignore.
    return;
  }
  this.readyState = goog.net.FetchXmlHttp.RequestState.DONE;
  this.dispatchCallback_();
};

/** @override */
goog.net.FetchXmlHttp.prototype.setRequestHeader = function(header, value) {
  this.requestHeaders_.append(header, value);
};

/** @override */
goog.net.FetchXmlHttp.prototype.getResponseHeader = function(header) {
  return this.responseHeaders_.get(header.toLowerCase()) || '';
};

/** @override */
goog.net.FetchXmlHttp.prototype.getAllResponseHeaders = function() {
  // TODO(user): Implement once the Headers extern support entries().
  return '';
};

/**
 * @param {!RequestCredentials} credentialsMode The credentials mode of the
 *     Service Worker fetch.
 */
goog.net.FetchXmlHttp.prototype.setCredentialsMode = function(credentialsMode) {
  this.credentialsMode_ = credentialsMode;
};

/**
 * @param {!RequestCache} cacheMode The cache mode of the Service Worker fetch.
 */
goog.net.FetchXmlHttp.prototype.setCacheMode = function(cacheMode) {
  this.cacheMode_ = cacheMode;
};

/**
 * Dispatches the callback, if the callback attribute is defined.
 * @private
 */
goog.net.FetchXmlHttp.prototype.dispatchCallback_ = function() {
  if (this.onreadystatechange) {
    this.onreadystatechange.call(this);
  }
};


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using HealthMonitoring.SelfHost.Entities;

namespace HealthMonitoring.SelfHost.Filters
{
    internal class EndpointFilter
    {
        private readonly List<Func<EndpointDetails, bool>> _filters = new List<Func<EndpointDetails, bool>> { e => true };
        public EndpointFilter WithStatus(string[] filterStatus)
        {
            if (filterStatus != null && filterStatus.Any())
            {
                _filters.Add(e =>
                {
                    var status = e.Status.ToString();
                    return filterStatus.Any(s => s.Equals(status, StringComparison.OrdinalIgnoreCase));
                });
            }

            return this;
        }

        public EndpointFilter WithTags(string[] filterTags)
        {
            if (filterTags != null && filterTags.Any())
                _filters.Add(e => filterTags.All(tag => e.Tags.Any(etag => etag.Equals(tag, StringComparison.OrdinalIgnoreCase))));

            return this;
        }

        public EndpointFilter WithGroup(string filterGroup)
        {
            if (!string.IsNullOrWhiteSpace(filterGroup))
            {
                var search = PrepareSearch(filterGroup, true);
                _filters.Add(e => search(e.Group));
            }
            return this;
        }

        public EndpointFilter WithText(string filterText)
        {
            if (!string.IsNullOrWhiteSpace(filterText))
            {
                var search = PrepareSearch(filterText, false);
                _filters.Add(e => search(e.Group) || search(e.Name) || search(e.Status.ToString()) || search(e.MonitorType) || search(e.Address));
            }
            return this;
        }

        private static Func<string, bool> PrepareSearch(string filter, bool exactMatch)
        {
            var pattern = Regex.Escape(filter).Replace("\\*", ".*").Replace("\\?", ".");
            if (exactMatch)
                pattern = "^" + pattern + "$";

            var regex = new Regex(pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);

            return regex.IsMatch;
        }

        public bool DoesMatch(EndpointDetails endpoint)
        {
            return _filters.All(f => f.Invoke(endpoint));
        }
    }
}


text:
package com.xiongyingqi.util.concurrent;

/**
 * Defines the contract for callbacks that accept the result of a
 * {@link ListenableFuture}.
 *
 * @author Arjen Poutsma
 * @since 4.0
 */
public interface ListenableFutureCallback<T> {

    /**
     * Called when the {@link ListenableFuture} successfully completes.
     *
     * @param result the result
     */
    void onSuccess(T result);

    /**
     * Called when the {@link ListenableFuture} fails to complete.
     *
     * @param t the exception that triggered the failure
     */
    void onFailure(Throwable t);

}