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

package com.google.cloud.iot.v1;

/**
 *
 *
 * <pre>
 * The device resource.
 * </pre>
 *
 * Protobuf type {@code google.cloud.iot.v1.Device}
 */
public final class Device extends com.google.protobuf.GeneratedMessageV3
    implements
    // @@protoc_insertion_point(message_implements:google.cloud.iot.v1.Device)
    DeviceOrBuilder {
  private static final long serialVersionUID = 0L;
  // Use Device.newBuilder() to construct.
  private Device(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
    super(builder);
  }

  private Device() {
    id_ = "";
    name_ = "";
    credentials_ = java.util.Collections.emptyList();
    logLevel_ = 0;
  }

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

  public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
    return com.google.cloud.iot.v1.ResourcesProto
        .internal_static_google_cloud_iot_v1_Device_descriptor;
  }

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

  @java.lang.Override
  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
      internalGetFieldAccessorTable() {
    return com.google.cloud.iot.v1.ResourcesProto
        .internal_static_google_cloud_iot_v1_Device_fieldAccessorTable
        .ensureFieldAccessorsInitialized(
            com.google.cloud.iot.v1.Device.class, com.google.cloud.iot.v1.Device.Builder.class);
  }

  public static final int ID_FIELD_NUMBER = 1;

  @SuppressWarnings("serial")
  private volatile java.lang.Object id_ = "";
  /**
   *
   *
   * <pre>
   * The user-defined device identifier. The device ID must be unique
   * within a device registry.
   * </pre>
   *
   * <code>string id = 1;</code>
   *
   * @return The id.
   */
  @java.lang.Override
  public java.lang.String getId() {
    java.lang.Object ref = id_;
    if (ref instanceof java.lang.String) {
      return (java.lang.String) ref;
    } else {
      com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
      java.lang.String s = bs.toStringUtf8();
      id_ = s;
      return s;
    }
  }
  /**
   *
   *
   * <pre>
   * The user-defined device identifier. The device ID must be unique
   * within a device registry.
   * </pre>
   *
   * <code>string id = 1;</code>
   *
   * @return The bytes for id.
   */
  @java.lang.Override
  public com.google.protobuf.ByteString getIdBytes() {
    java.lang.Object ref = id_;
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b =
          com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
      id_ = b;
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }

  public static final int NAME_FIELD_NUMBER = 2;

  @SuppressWarnings("serial")
  private volatile java.lang.Object name_ = "";
  /**
   *
   *
   * <pre>
   * The resource path name. For example,
   * `projects/p1/locations/us-central1/registries/registry0/devices/dev0` or
   * `projects/p1/locations/us-central1/registries/registry0/devices/{num_id}`.
   * When `name` is populated as a response from the service, it always ends
   * in the device numeric ID.
   * </pre>
   *
   * <code>string name = 2;</code>
   *
   * @return The name.
   */
  @java.lang.Override
  public java.lang.String getName() {
    java.lang.Object ref = name_;
    if (ref instanceof java.lang.String) {
      return (java.lang.String) ref;
    } else {
      com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
      java.lang.String s = bs.toStringUtf8();
      name_ = s;
      return s;
    }
  }
  /**
   *
   *
   * <pre>
   * The resource path name. For example,
   * `projects/p1/locations/us-central1/registries/registry0/devices/dev0` or
   * `projects/p1/locations/us-central1/registries/registry0/devices/{num_id}`.
   * When `name` is populated as a response from the service, it always ends
   * in the device numeric ID.
   * </pre>
   *
   * <code>string name = 2;</code>
   *
   * @return The bytes for name.
   */
  @java.lang.Override
  public com.google.protobuf.ByteString getNameBytes() {
    java.lang.Object ref = name_;
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b =
          com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
      name_ = b;
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }

  public static final int NUM_ID_FIELD_NUMBER = 3;
  private long numId_ = 0L;
  /**
   *
   *
   * <pre>
   * [Output only] A server-defined unique numeric ID for the device. This is a
   * more compact way to identify devices, and it is globally unique.
   * </pre>
   *
   * <code>uint64 num_id = 3;</code>
   *
   * @return The numId.
   */
  @java.lang.Override
  public long getNumId() {
    return numId_;
  }

  public static final int CREDENTIALS_FIELD_NUMBER = 12;

  @SuppressWarnings("serial")
  private java.util.List<com.google.cloud.iot.v1.DeviceCredential> credentials_;
  /**
   *
   *
   * <pre>
   * The credentials used to authenticate this device. To allow credential
   * rotation without interruption, multiple device credentials can be bound to
   * this device. No more than 3 credentials can be bound to a single device at
   * a time. When new credentials are added to a device, they are verified
   * against the registry credentials. For details, see the description of the
   * `DeviceRegistry.credentials` field.
   * </pre>
   *
   * <code>repeated .google.cloud.iot.v1.DeviceCredential credentials = 12;</code>
   */
  @java.lang.Override
  public java.util.List<com.google.cloud.iot.v1.DeviceCredential> getCredentialsList() {
    return credentials_;
  }
  /**
   *
   *
   * <pre>
   * The credentials used to authenticate this device. To allow credential
   * rotation without interruption, multiple device credentials can be bound to
   * this device. No more than 3 credentials can be bound to a single device at
   * a time. When new credentials are added to a device, they are verified
   * against the registry credentials. For details, see the description of the
   * `DeviceRegistry.credentials` field.
   * </pre>
   *
   * <code>repeated .google.cloud.iot.v1.DeviceCredential credentials = 12;</code>
   */
  @java.lang.Override
  public java.util.List<? extends com.google.cloud.iot.v1.DeviceCredentialOrBuilder>
      getCredentialsOrBuilderList() {
    return credentials_;
  }
  /**
   *
   *
   * <pre>
   * The credentials used to authenticate this device. To allow credential
   * rotation without interruption, multiple device credentials can be bound to
   * this device. No more than 3 credentials can be bound to a single device at
   * a time. When new credentials are added to a device, they are verified
   * against the registry credentials. For details, see the description of the
   * `DeviceRegistry.credentials` field.
   * </pre>
   *
   * <code>repeated .google.cloud.iot.v1.DeviceCredential credentials = 12;</code>
   */
  @java.lang.Override
  public int getCredentialsCount() {
    return credentials_.size();
  }
  /**
   *
   *
   * <pre>
   * The credentials used to authenticate this device. To allow credential
   * rotation without interruption, multiple device credentials can be bound to
   * this device. No more than 3 credentials can be bound to a single device at
   * a time. When new credentials are added to a device, they are verified
   * against the registry credentials. For details, see the description of the
   * `DeviceRegistry.credentials` field.
   * </pre>
   *
   * <code>repeated .google.cloud.iot.v1.DeviceCredential credentials = 12;</code>
   */
  @java.lang.Override
  public com.google.cloud.iot.v1.DeviceCredential getCredentials(int index) {
    return credentials_.get(index);
  }
  /**
   *
   *
   * <pre>
   * The credentials used to authenticate this device. To allow credential
   * rotation without interruption, multiple device credentials can be bound to
   * this device. No more than 3 credentials can be bound to a single device at
   * a time. When new credentials are added to a device, they are verified
   * against the registry credentials. For details, see the description of the
   * `DeviceRegistry.credentials` field.
   * </pre>
   *
   * <code>repeated .google.cloud.iot.v1.DeviceCredential credentials = 12;</code>
   */
  @java.lang.Override
  public com.google.cloud.iot.v1.DeviceCredentialOrBuilder getCredentialsOrBuilder(int index) {
    return credentials_.get(index);
  }

  public static final int LAST_HEARTBEAT_TIME_FIELD_NUMBER = 7;
  private com.google.protobuf.Timestamp lastHeartbeatTime_;
  /**
   *
   *
   * <pre>
   * [Output only] The last time an MQTT `PINGREQ` was received. This field
   * applies only to devices connecting through MQTT. MQTT clients usually only
   * send `PINGREQ` messages if the connection is idle, and no other messages
   * have been sent. Timestamps are periodically collected and written to
   * storage; they may be stale by a few minutes.
   * </pre>
   *
   * <code>.google.protobuf.Timestamp last_heartbeat_time = 7;</code>
   *
   * @return Whether the lastHeartbeatTime field is set.
   */
  @java.lang.Override
  public boolean hasLastHeartbeatTime() {
    return lastHeartbeatTime_ != null;
  }
  /**
   *
   *
   * <pre>
   * [Output only] The last time an MQTT `PINGREQ` was received. This field
   * applies only to devices connecting through MQTT. MQTT clients usually only
   * send `PINGREQ` messages if the connection is idle, and no other messages
   * have been sent. Timestamps are periodically collected and written to
   * storage; they may be stale by a few minutes.
   * </pre>
   *
   * <code>.google.protobuf.Timestamp last_heartbeat_time = 7;</code>
   *
   * @return The lastHeartbeatTime.
   */
  @java.lang.Override
  public com.google.protobuf.Timestamp getLastHeartbeatTime() {
    return lastHeartbeatTime_ == null
        ? com.google.protobuf.Timestamp.getDefaultInstance()
        : lastHeartbeatTime_;
  }
  /**
   *
   *
   * <pre>
   * [Output only] The last time an MQTT `PINGREQ` was received. This field
   * applies only to devices connecting through MQTT. MQTT clients usually only
   * send `PINGREQ` messages if the connection is idle, and no other messages
   * have been sent. Timestamps are periodically collected and written to
   * storage; they may be stale by a few minutes.
   * </pre>
   *
   * <code>.google.protobuf.Timestamp last_heartbeat_time = 7;</code>
   */
  @java.lang.Override
  public com.google.protobuf.TimestampOrBuilder getLastHeartbeatTimeOrBuilder() {
    return lastHeartbeatTime_ == null
        ? com.google.protobuf.Timestamp.getDefaultInstance()
        : lastHeartbeatTime_;
  }

  public static final int LAST_EVENT_TIME_FIELD_NUMBER = 8;
  private com.google.protobuf.Timestamp lastEventTime_;
  /**
   *
   *
   * <pre>
   * [Output only] The last time a telemetry event was received. Timestamps are
   * periodically collected and written to storage; they may be stale by a few
   * minutes.
   * </pre>
   *
   * <code>.google.protobuf.Timestamp last_event_time = 8;</code>
   *
   * @return Whether the lastEventTime field is set.
   */
  @java.lang.Override
  public boolean hasLastEventTime() {
    return lastEventTime_ != null;
  }
  /**
   *
   *
   * <pre>
   * [Output only] The last time a telemetry event was received. Timestamps are
   * periodically collected and written to storage; they may be stale by a few
   * minutes.
   * </pre>
   *
   * <code>.google.protobuf.Timestamp last_event_time = 8;</code>
   *
   * @return The lastEventTime.
   */
  @java.lang.Override
  public com.google.protobuf.Timestamp getLastEventTime() {
    return lastEventTime_ == null
        ? com.google.protobuf.Timestamp.getDefaultInstance()
        : lastEventTime_;
  }
  /**
   *
   *
   * <pre>
   * [Output only] The last time a telemetry event was received. Timestamps are
   * periodically collected and written to storage; they may be stale by a few
   * minutes.
   * </pre>
   *
   * <code>.google.protobuf.Timestamp last_event_time = 8;</code>
   */
  @java.lang.Override
  public com.google.protobuf.TimestampOrBuilder getLastEventTimeOrBuilder() {
    return lastEventTime_ == null
        ? com.google.protobuf.Timestamp.getDefaultInstance()
        : lastEventTime_;
  }

  public static final int LAST_STATE_TIME_FIELD_NUMBER = 20;
  private com.google.protobuf.Timestamp lastStateTime_;
  /**
   *
   *
   * <pre>
   * [Output only] The last time a state event was received. Timestamps are
   * periodically collected and written to storage; they may be stale by a few
   * minutes.
   * </pre>
   *
   * <code>.google.protobuf.Timestamp last_state_time = 20;</code>
   *
   * @return Whether the lastStateTime field is set.
   */
  @java.lang.Override
  public boolean hasLastStateTime() {
    return lastStateTime_ != null;
  }
  /**
   *
   *
   * <pre>
   * [Output only] The last time a state event was received. Timestamps are
   * periodically collected and written to storage; they may be stale by a few
   * minutes.
   * </pre>
   *
   * <code>.google.protobuf.Timestamp last_state_time = 20;</code>
   *
   * @return The lastStateTime.
   */
  @java.lang.Override
  public com.google.protobuf.Timestamp getLastStateTime() {
    return lastStateTime_ == null
        ? com.google.protobuf.Timestamp.getDefaultInstance()
        : lastStateTime_;
  }
  /**
   *
   *
   * <pre>
   * [Output only] The last time a state event was received. Timestamps are
   * periodically collected and written to storage; they may be stale by a few
   * minutes.
   * </pre>
   *
   * <code>.google.protobuf.Timestamp last_state_time = 20;</code>
   */
  @java.lang.Override
  public com.google.protobuf.TimestampOrBuilder getLastStateTimeOrBuilder() {
    return lastStateTime_ == null
        ? com.google.protobuf.Timestamp.getDefaultInstance()
        : lastStateTime_;
  }

  public static final int LAST_CONFIG_ACK_TIME_FIELD_NUMBER = 14;
  private com.google.protobuf.Timestamp lastConfigAckTime_;
  /**
   *
   *
   * <pre>
   * [Output only] The last time a cloud-to-device config version acknowledgment
   * was received from the device. This field is only for configurations
   * sent through MQTT.
   * </pre>
   *
   * <code>.google.protobuf.Timestamp last_config_ack_time = 14;</code>
   *
   * @return Whether the lastConfigAckTime field is set.
   */
  @java.lang.Override
  public boolean hasLastConfigAckTime() {
    return lastConfigAckTime_ != null;
  }
  /**
   *
   *
   * <pre>
   * [Output only] The last time a cloud-to-device config version acknowledgment
   * was received from the device. This field is only for configurations
   * sent through MQTT.
   * </pre>
   *
   * <code>.google.protobuf.Timestamp last_config_ack_time = 14;</code>
   *
   * @return The lastConfigAckTime.
   */
  @java.lang.Override
  public com.google.protobuf.Timestamp getLastConfigAckTime() {
    return lastConfigAckTime_ == null
        ? com.google.protobuf.Timestamp.getDefaultInstance()
        : lastConfigAckTime_;
  }
  /**
   *
   *
   * <pre>
   * [Output only] The last time a cloud-to-device config version acknowledgment
   * was received from the device. This field is only for configurations
   * sent through MQTT.
   * </pre>
   *
   * <code>.google.protobuf.Timestamp last_config_ack_time = 14;</code>
   */
  @java.lang.Override
  public com.google.protobuf.TimestampOrBuilder getLastConfigAckTimeOrBuilder() {
    return lastConfigAckTime_ == null
        ? com.google.protobuf.Timestamp.getDefaultInstance()
        : lastConfigAckTime_;
  }

  public static final int LAST_CONFIG_SEND_TIME_FIELD_NUMBER = 18;
  private com.google.protobuf.Timestamp lastConfigSendTime_;
  /**
   *
   *
   * <pre>
   * [Output only] The last time a cloud-to-device config version was sent to
   * the device.
   * </pre>
   *
   * <code>.google.protobuf.Timestamp last_config_send_time = 18;</code>
   *
   * @return Whether the lastConfigSendTime field is set.
   */
  @java.lang.Override
  public boolean hasLastConfigSendTime() {
    return lastConfigSendTime_ != null;
  }
  /**
   *
   *
   * <pre>
   * [Output only] The last time a cloud-to-device config version was sent to
   * the device.
   * </pre>
   *
   * <code>.google.protobuf.Timestamp last_config_send_time = 18;</code>
   *
   * @return The lastConfigSendTime.
   */
  @java.lang.Override
  public com.google.protobuf.Timestamp getLastConfigSendTime() {
    return lastConfigSendTime_ == null
        ? com.google.protobuf.Timestamp.getDefaultInstance()
        : lastConfigSendTime_;
  }
  /**
   *
   *
   * <pre>
   * [Output only] The last time a cloud-to-device config version was sent to
   * the device.
   * </pre>
   *
   * <code>.google.protobuf.Timestamp last_config_send_time = 18;</code>
   */
  @java.lang.Override
  public com.google.protobuf.TimestampOrBuilder getLastConfigSendTimeOrBuilder() {
    return lastConfigSendTime_ == null
        ? com.google.protobuf.Timestamp.getDefaultInstance()
        : lastConfigSendTime_;
  }

  public static final int BLOCKED_FIELD_NUMBER = 19;
  private boolean blocked_ = false;
  /**
   *
   *
   * <pre>
   * If a device is blocked, connections or requests from this device will fail.
   * Can be used to temporarily prevent the device from connecting if, for
   * example, the sensor is generating bad data and needs maintenance.
   * </pre>
   *
   * <code>bool blocked = 19;</code>
   *
   * @return The blocked.
   */
  @java.lang.Override
  public boolean getBlocked() {
    return blocked_;
  }

  public static final int LAST_ERROR_TIME_FIELD_NUMBER = 10;
  private com.google.protobuf.Timestamp lastErrorTime_;
  /**
   *
   *
   * <pre>
   * [Output only] The time the most recent error occurred, such as a failure to
   * publish to Cloud Pub/Sub. This field is the timestamp of
   * 'last_error_status'.
   * </pre>
   *
   * <code>.google.protobuf.Timestamp last_error_time = 10;</code>
   *
   * @return Whether the lastErrorTime field is set.
   */
  @java.lang.Override
  public boolean hasLastErrorTime() {
    return lastErrorTime_ != null;
  }
  /**
   *
   *
   * <pre>
   * [Output only] The time the most recent error occurred, such as a failure to
   * publish to Cloud Pub/Sub. This field is the timestamp of
   * 'last_error_status'.
   * </pre>
   *
   * <code>.google.protobuf.Timestamp last_error_time = 10;</code>
   *
   * @return The lastErrorTime.
   */
  @java.lang.Override
  public com.google.protobuf.Timestamp getLastErrorTime() {
    return lastErrorTime_ == null
        ? com.google.protobuf.Timestamp.getDefaultInstance()
        : lastErrorTime_;
  }
  /**
   *
   *
   * <pre>
   * [Output only] The time the most recent error occurred, such as a failure to
   * publish to Cloud Pub/Sub. This field is the timestamp of
   * 'last_error_status'.
   * </pre>
   *
   * <code>.google.protobuf.Timestamp last_error_time = 10;</code>
   */
  @java.lang.Override
  public com.google.protobuf.TimestampOrBuilder getLastErrorTimeOrBuilder() {
    return lastErrorTime_ == null
        ? com.google.protobuf.Timestamp.getDefaultInstance()
        : lastErrorTime_;
  }

  public static final int LAST_ERROR_STATUS_FIELD_NUMBER = 11;
  private com.google.rpc.Status lastErrorStatus_;
  /**
   *
   *
   * <pre>
   * [Output only] The error message of the most recent error, such as a failure
   * to publish to Cloud Pub/Sub. 'last_error_time' is the timestamp of this
   * field. If no errors have occurred, this field has an empty message
   * and the status code 0 == OK. Otherwise, this field is expected to have a
   * status code other than OK.
   * </pre>
   *
   * <code>.google.rpc.Status last_error_status = 11;</code>
   *
   * @return Whether the lastErrorStatus field is set.
   */
  @java.lang.Override
  public boolean hasLastErrorStatus() {
    return lastErrorStatus_ != null;
  }
  /**
   *
   *
   * <pre>
   * [Output only] The error message of the most recent error, such as a failure
   * to publish to Cloud Pub/Sub. 'last_error_time' is the timestamp of this
   * field. If no errors have occurred, this field has an empty message
   * and the status code 0 == OK. Otherwise, this field is expected to have a
   * status code other than OK.
   * </pre>
   *
   * <code>.google.rpc.Status last_error_status = 11;</code>
   *
   * @return The lastErrorStatus.
   */
  @java.lang.Override
  public com.google.rpc.Status getLastErrorStatus() {
    return lastErrorStatus_ == null ? com.google.rpc.Status.getDefaultInstance() : lastErrorStatus_;
  }
  /**
   *
   *
   * <pre>
   * [Output only] The error message of the most recent error, such as a failure
   * to publish to Cloud Pub/Sub. 'last_error_time' is the timestamp of this
   * field. If no errors have occurred, this field has an empty message
   * and the status code 0 == OK. Otherwise, this field is expected to have a
   * status code other than OK.
   * </pre>
   *
   * <code>.google.rpc.Status last_error_status = 11;</code>
   */
  @java.lang.Override
  public com.google.rpc.StatusOrBuilder getLastErrorStatusOrBuilder() {
    return lastErrorStatus_ == null ? com.google.rpc.Status.getDefaultInstance() : lastErrorStatus_;
  }

  public static final int CONFIG_FIELD_NUMBER = 13;
  private com.google.cloud.iot.v1.DeviceConfig config_;
  /**
   *
   *
   * <pre>
   * The most recent device configuration, which is eventually sent from
   * Cloud IoT Core to the device. If not present on creation, the
   * configuration will be initialized with an empty payload and version value
   * of `1`. To update this field after creation, use the
   * `DeviceManager.ModifyCloudToDeviceConfig` method.
   * </pre>
   *
   * <code>.google.cloud.iot.v1.DeviceConfig config = 13;</code>
   *
   * @return Whether the config field is set.
   */
  @java.lang.Override
  public boolean hasConfig() {
    return config_ != null;
  }
  /**
   *
   *
   * <pre>
   * The most recent device configuration, which is eventually sent from
   * Cloud IoT Core to the device. If not present on creation, the
   * configuration will be initialized with an empty payload and version value
   * of `1`. To update this field after creation, use the
   * `DeviceManager.ModifyCloudToDeviceConfig` method.
   * </pre>
   *
   * <code>.google.cloud.iot.v1.DeviceConfig config = 13;</code>
   *
   * @return The config.
   */
  @java.lang.Override
  public com.google.cloud.iot.v1.DeviceConfig getConfig() {
    return config_ == null ? com.google.cloud.iot.v1.DeviceConfig.getDefaultInstance() : config_;
  }
  /**
   *
   *
   * <pre>
   * The most recent device configuration, which is eventually sent from
   * Cloud IoT Core to the device. If not present on creation, the
   * configuration will be initialized with an empty payload and version value
   * of `1`. To update this field after creation, use the
   * `DeviceManager.ModifyCloudToDeviceConfig` method.
   * </pre>
   *
   * <code>.google.cloud.iot.v1.DeviceConfig config = 13;</code>
   */
  @java.lang.Override
  public com.google.cloud.iot.v1.DeviceConfigOrBuilder getConfigOrBuilder() {
    return config_ == null ? com.google.cloud.iot.v1.DeviceConfig.getDefaultInstance() : config_;
  }

  public static final int STATE_FIELD_NUMBER = 16;
  private com.google.cloud.iot.v1.DeviceState state_;
  /**
   *
   *
   * <pre>
   * [Output only] The state most recently received from the device. If no state
   * has been reported, this field is not present.
   * </pre>
   *
   * <code>.google.cloud.iot.v1.DeviceState state = 16;</code>
   *
   * @return Whether the state field is set.
   */
  @java.lang.Override
  public boolean hasState() {
    return state_ != null;
  }
  /**
   *
   *
   * <pre>
   * [Output only] The state most recently received from the device. If no state
   * has been reported, this field is not present.
   * </pre>
   *
   * <code>.google.cloud.iot.v1.DeviceState state = 16;</code>
   *
   * @return The state.
   */
  @java.lang.Override
  public com.google.cloud.iot.v1.DeviceState getState() {
    return state_ == null ? com.google.cloud.iot.v1.DeviceState.getDefaultInstance() : state_;
  }
  /**
   *
   *
   * <pre>
   * [Output only] The state most recently received from the device. If no state
   * has been reported, this field is not present.
   * </pre>
   *
   * <code>.google.cloud.iot.v1.DeviceState state = 16;</code>
   */
  @java.lang.Override
  public com.google.cloud.iot.v1.DeviceStateOrBuilder getStateOrBuilder() {
    return state_ == null ? com.google.cloud.iot.v1.DeviceState.getDefaultInstance() : state_;
  }

  public static final int LOG_LEVEL_FIELD_NUMBER = 21;
  private int logLevel_ = 0;
  /**
   *
   *
   * <pre>
   * **Beta Feature**
   *
   * The logging verbosity for device activity. If unspecified,
   * DeviceRegistry.log_level will be used.
   * </pre>
   *
   * <code>.google.cloud.iot.v1.LogLevel log_level = 21;</code>
   *
   * @return The enum numeric value on the wire for logLevel.
   */
  @java.lang.Override
  public int getLogLevelValue() {
    return logLevel_;
  }
  /**
   *
   *
   * <pre>
   * **Beta Feature**
   *
   * The logging verbosity for device activity. If unspecified,
   * DeviceRegistry.log_level will be used.
   * </pre>
   *
   * <code>.google.cloud.iot.v1.LogLevel log_level = 21;</code>
   *
   * @return The logLevel.
   */
  @java.lang.Override
  public com.google.cloud.iot.v1.LogLevel getLogLevel() {
    com.google.cloud.iot.v1.LogLevel result = com.google.cloud.iot.v1.LogLevel.forNumber(logLevel_);
    return result == null ? com.google.cloud.iot.v1.LogLevel.UNRECOGNIZED : result;
  }

  public static final int METADATA_FIELD_NUMBER = 17;

  private static final class MetadataDefaultEntryHolder {
    static final com.google.protobuf.MapEntry<java.lang.String, java.lang.String> defaultEntry =
        com.google.protobuf.MapEntry.<java.lang.String, java.lang.String>newDefaultInstance(
            com.google.cloud.iot.v1.ResourcesProto
                .internal_static_google_cloud_iot_v1_Device_MetadataEntry_descriptor,
            com.google.protobuf.WireFormat.FieldType.STRING,
            "",
            com.google.protobuf.WireFormat.FieldType.STRING,
            "");
  }

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

  private com.google.protobuf.MapField<java.lang.String, java.lang.String> internalGetMetadata() {
    if (metadata_ == null) {
      return com.google.protobuf.MapField.emptyMapField(MetadataDefaultEntryHolder.defaultEntry);
    }
    return metadata_;
  }

  public int getMetadataCount() {
    return internalGetMetadata().getMap().size();
  }
  /**
   *
   *
   * <pre>
   * The metadata key-value pairs assigned to the device. This metadata is not
   * interpreted or indexed by Cloud IoT Core. It can be used to add contextual
   * information for the device.
   *
   * Keys must conform to the regular expression [a-zA-Z][a-zA-Z0-9-_.+~%]+ and
   * be less than 128 bytes in length.
   *
   * Values are free-form strings. Each value must be less than or equal to 32
   * KB in size.
   *
   * The total size of all keys and values must be less than 256 KB, and the
   * maximum number of key-value pairs is 500.
   * </pre>
   *
   * <code>map&lt;string, string&gt; metadata = 17;</code>
   */
  @java.lang.Override
  public boolean containsMetadata(java.lang.String key) {
    if (key == null) {
      throw new NullPointerException("map key");
    }
    return internalGetMetadata().getMap().containsKey(key);
  }
  /** Use {@link #getMetadataMap()} instead. */
  @java.lang.Override
  @java.lang.Deprecated
  public java.util.Map<java.lang.String, java.lang.String> getMetadata() {
    return getMetadataMap();
  }
  /**
   *
   *
   * <pre>
   * The metadata key-value pairs assigned to the device. This metadata is not
   * interpreted or indexed by Cloud IoT Core. It can be used to add contextual
   * information for the device.
   *
   * Keys must conform to the regular expression [a-zA-Z][a-zA-Z0-9-_.+~%]+ and
   * be less than 128 bytes in length.
   *
   * Values are free-form strings. Each value must be less than or equal to 32
   * KB in size.
   *
   * The total size of all keys and values must be less than 256 KB, and the
   * maximum number of key-value pairs is 500.
   * </pre>
   *
   * <code>map&lt;string, string&gt; metadata = 17;</code>
   */
  @java.lang.Override
  public java.util.Map<java.lang.String, java.lang.String> getMetadataMap() {
    return internalGetMetadata().getMap();
  }
  /**
   *
   *
   * <pre>
   * The metadata key-value pairs assigned to the device. This metadata is not
   * interpreted or indexed by Cloud IoT Core. It can be used to add contextual
   * information for the device.
   *
   * Keys must conform to the regular expression [a-zA-Z][a-zA-Z0-9-_.+~%]+ and
   * be less than 128 bytes in length.
   *
   * Values are free-form strings. Each value must be less than or equal to 32
   * KB in size.
   *
   * The total size of all keys and values must be less than 256 KB, and the
   * maximum number of key-value pairs is 500.
   * </pre>
   *
   * <code>map&lt;string, string&gt; metadata = 17;</code>
   */
  @java.lang.Override
  public /* nullable */ java.lang.String getMetadataOrDefault(
      java.lang.String key,
      /* nullable */
      java.lang.String defaultValue) {
    if (key == null) {
      throw new NullPointerException("map key");
    }
    java.util.Map<java.lang.String, java.lang.String> map = internalGetMetadata().getMap();
    return map.containsKey(key) ? map.get(key) : defaultValue;
  }
  /**
   *
   *
   * <pre>
   * The metadata key-value pairs assigned to the device. This metadata is not
   * interpreted or indexed by Cloud IoT Core. It can be used to add contextual
   * information for the device.
   *
   * Keys must conform to the regular expression [a-zA-Z][a-zA-Z0-9-_.+~%]+ and
   * be less than 128 bytes in length.
   *
   * Values are free-form strings. Each value must be less than or equal to 32
   * KB in size.
   *
   * The total size of all keys and values must be less than 256 KB, and the
   * maximum number of key-value pairs is 500.
   * </pre>
   *
   * <code>map&lt;string, string&gt; metadata = 17;</code>
   */
  @java.lang.Override
  public java.lang.String getMetadataOrThrow(java.lang.String key) {
    if (key == null) {
      throw new NullPointerException("map key");
    }
    java.util.Map<java.lang.String, java.lang.String> map = internalGetMetadata().getMap();
    if (!map.containsKey(key)) {
      throw new java.lang.IllegalArgumentException();
    }
    return map.get(key);
  }

  public static final int GATEWAY_CONFIG_FIELD_NUMBER = 24;
  private com.google.cloud.iot.v1.GatewayConfig gatewayConfig_;
  /**
   *
   *
   * <pre>
   * Gateway-related configuration and state.
   * </pre>
   *
   * <code>.google.cloud.iot.v1.GatewayConfig gateway_config = 24;</code>
   *
   * @return Whether the gatewayConfig field is set.
   */
  @java.lang.Override
  public boolean hasGatewayConfig() {
    return gatewayConfig_ != null;
  }
  /**
   *
   *
   * <pre>
   * Gateway-related configuration and state.
   * </pre>
   *
   * <code>.google.cloud.iot.v1.GatewayConfig gateway_config = 24;</code>
   *
   * @return The gatewayConfig.
   */
  @java.lang.Override
  public com.google.cloud.iot.v1.GatewayConfig getGatewayConfig() {
    return gatewayConfig_ == null
        ? com.google.cloud.iot.v1.GatewayConfig.getDefaultInstance()
        : gatewayConfig_;
  }
  /**
   *
   *
   * <pre>
   * Gateway-related configuration and state.
   * </pre>
   *
   * <code>.google.cloud.iot.v1.GatewayConfig gateway_config = 24;</code>
   */
  @java.lang.Override
  public com.google.cloud.iot.v1.GatewayConfigOrBuilder getGatewayConfigOrBuilder() {
    return gatewayConfig_ == null
        ? com.google.cloud.iot.v1.GatewayConfig.getDefaultInstance()
        : gatewayConfig_;
  }

  private byte memoizedIsInitialized = -1;

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

    memoizedIsInitialized = 1;
    return true;
  }

  @java.lang.Override
  public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException {
    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(id_)) {
      com.google.protobuf.GeneratedMessageV3.writeString(output, 1, id_);
    }
    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) {
      com.google.protobuf.GeneratedMessageV3.writeString(output, 2, name_);
    }
    if (numId_ != 0L) {
      output.writeUInt64(3, numId_);
    }
    if (lastHeartbeatTime_ != null) {
      output.writeMessage(7, getLastHeartbeatTime());
    }
    if (lastEventTime_ != null) {
      output.writeMessage(8, getLastEventTime());
    }
    if (lastErrorTime_ != null) {
      output.writeMessage(10, getLastErrorTime());
    }
    if (lastErrorStatus_ != null) {
      output.writeMessage(11, getLastErrorStatus());
    }
    for (int i = 0; i < credentials_.size(); i++) {
      output.writeMessage(12, credentials_.get(i));
    }
    if (config_ != null) {
      output.writeMessage(13, getConfig());
    }
    if (lastConfigAckTime_ != null) {
      output.writeMessage(14, getLastConfigAckTime());
    }
    if (state_ != null) {
      output.writeMessage(16, getState());
    }
    com.google.protobuf.GeneratedMessageV3.serializeStringMapTo(
        output, internalGetMetadata(), MetadataDefaultEntryHolder.defaultEntry, 17);
    if (lastConfigSendTime_ != null) {
      output.writeMessage(18, getLastConfigSendTime());
    }
    if (blocked_ != false) {
      output.writeBool(19, blocked_);
    }
    if (lastStateTime_ != null) {
      output.writeMessage(20, getLastStateTime());
    }
    if (logLevel_ != com.google.cloud.iot.v1.LogLevel.LOG_LEVEL_UNSPECIFIED.getNumber()) {
      output.writeEnum(21, logLevel_);
    }
    if (gatewayConfig_ != null) {
      output.writeMessage(24, getGatewayConfig());
    }
    getUnknownFields().writeTo(output);
  }

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

    size = 0;
    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(id_)) {
      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, id_);
    }
    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) {
      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, name_);
    }
    if (numId_ != 0L) {
      size += com.google.protobuf.CodedOutputStream.computeUInt64Size(3, numId_);
    }
    if (lastHeartbeatTime_ != null) {
      size += com.google.protobuf.CodedOutputStream.computeMessageSize(7, getLastHeartbeatTime());
    }
    if (lastEventTime_ != null) {
      size += com.google.protobuf.CodedOutputStream.computeMessageSize(8, getLastEventTime());
    }
    if (lastErrorTime_ != null) {
      size += com.google.protobuf.CodedOutputStream.computeMessageSize(10, getLastErrorTime());
    }
    if (lastErrorStatus_ != null) {
      size += com.google.protobuf.CodedOutputStream.computeMessageSize(11, getLastErrorStatus());
    }
    for (int i = 0; i < credentials_.size(); i++) {
      size += com.google.protobuf.CodedOutputStream.computeMessageSize(12, credentials_.get(i));
    }
    if (config_ != null) {
      size += com.google.protobuf.CodedOutputStream.computeMessageSize(13, getConfig());
    }
    if (lastConfigAckTime_ != null) {
      size += com.google.protobuf.CodedOutputStream.computeMessageSize(14, getLastConfigAckTime());
    }
    if (state_ != null) {
      size += com.google.protobuf.CodedOutputStream.computeMessageSize(16, getState());
    }
    for (java.util.Map.Entry<java.lang.String, java.lang.String> entry :
        internalGetMetadata().getMap().entrySet()) {
      com.google.protobuf.MapEntry<java.lang.String, java.lang.String> metadata__ =
          MetadataDefaultEntryHolder.defaultEntry
              .newBuilderForType()
              .setKey(entry.getKey())
              .setValue(entry.getValue())
              .build();
      size += com.google.protobuf.CodedOutputStream.computeMessageSize(17, metadata__);
    }
    if (lastConfigSendTime_ != null) {
      size += com.google.protobuf.CodedOutputStream.computeMessageSize(18, getLastConfigSendTime());
    }
    if (blocked_ != false) {
      size += com.google.protobuf.CodedOutputStream.computeBoolSize(19, blocked_);
    }
    if (lastStateTime_ != null) {
      size += com.google.protobuf.CodedOutputStream.computeMessageSize(20, getLastStateTime());
    }
    if (logLevel_ != com.google.cloud.iot.v1.LogLevel.LOG_LEVEL_UNSPECIFIED.getNumber()) {
      size += com.google.protobuf.CodedOutputStream.computeEnumSize(21, logLevel_);
    }
    if (gatewayConfig_ != null) {
      size += com.google.protobuf.CodedOutputStream.computeMessageSize(24, getGatewayConfig());
    }
    size += getUnknownFields().getSerializedSize();
    memoizedSize = size;
    return size;
  }

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

    if (!getId().equals(other.getId())) return false;
    if (!getName().equals(other.getName())) return false;
    if (getNumId() != other.getNumId()) return false;
    if (!getCredentialsList().equals(other.getCredentialsList())) return false;
    if (hasLastHeartbeatTime() != other.hasLastHeartbeatTime()) return false;
    if (hasLastHeartbeatTime()) {
      if (!getLastHeartbeatTime().equals(other.getLastHeartbeatTime())) return false;
    }
    if (hasLastEventTime() != other.hasLastEventTime()) return false;
    if (hasLastEventTime()) {
      if (!getLastEventTime().equals(other.getLastEventTime())) return false;
    }
    if (hasLastStateTime() != other.hasLastStateTime()) return false;
    if (hasLastStateTime()) {
      if (!getLastStateTime().equals(other.getLastStateTime())) return false;
    }
    if (hasLastConfigAckTime() != other.hasLastConfigAckTime()) return false;
    if (hasLastConfigAckTime()) {
      if (!getLastConfigAckTime().equals(other.getLastConfigAckTime())) return false;
    }
    if (hasLastConfigSendTime() != other.hasLastConfigSendTime()) return false;
    if (hasLastConfigSendTime()) {
      if (!getLastConfigSendTime().equals(other.getLastConfigSendTime())) return false;
    }
    if (getBlocked() != other.getBlocked()) return false;
    if (hasLastErrorTime() != other.hasLastErrorTime()) return false;
    if (hasLastErrorTime()) {
      if (!getLastErrorTime().equals(other.getLastErrorTime())) return false;
    }
    if (hasLastErrorStatus() != other.hasLastErrorStatus()) return false;
    if (hasLastErrorStatus()) {
      if (!getLastErrorStatus().equals(other.getLastErrorStatus())) return false;
    }
    if (hasConfig() != other.hasConfig()) return false;
    if (hasConfig()) {
      if (!getConfig().equals(other.getConfig())) return false;
    }
    if (hasState() != other.hasState()) return false;
    if (hasState()) {
      if (!getState().equals(other.getState())) return false;
    }
    if (logLevel_ != other.logLevel_) return false;
    if (!internalGetMetadata().equals(other.internalGetMetadata())) return false;
    if (hasGatewayConfig() != other.hasGatewayConfig()) return false;
    if (hasGatewayConfig()) {
      if (!getGatewayConfig().equals(other.getGatewayConfig())) return false;
    }
    if (!getUnknownFields().equals(other.getUnknownFields())) return false;
    return true;
  }

  @java.lang.Override
  public int hashCode() {
    if (memoizedHashCode != 0) {
      return memoizedHashCode;
    }
    int hash = 41;
    hash = (19 * hash) + getDescriptor().hashCode();
    hash = (37 * hash) + ID_FIELD_NUMBER;
    hash = (53 * hash) + getId().hashCode();
    hash = (37 * hash) + NAME_FIELD_NUMBER;
    hash = (53 * hash) + getName().hashCode();
    hash = (37 * hash) + NUM_ID_FIELD_NUMBER;
    hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getNumId());
    if (getCredentialsCount() > 0) {
      hash = (37 * hash) + CREDENTIALS_FIELD_NUMBER;
      hash = (53 * hash) + getCredentialsList().hashCode();
    }
    if (hasLastHeartbeatTime()) {
      hash = (37 * hash) + LAST_HEARTBEAT_TIME_FIELD_NUMBER;
      hash = (53 * hash) + getLastHeartbeatTime().hashCode();
    }
    if (hasLastEventTime()) {
      hash = (37 * hash) + LAST_EVENT_TIME_FIELD_NUMBER;
      hash = (53 * hash) + getLastEventTime().hashCode();
    }
    if (hasLastStateTime()) {
      hash = (37 * hash) + LAST_STATE_TIME_FIELD_NUMBER;
      hash = (53 * hash) + getLastStateTime().hashCode();
    }
    if (hasLastConfigAckTime()) {
      hash = (37 * hash) + LAST_CONFIG_ACK_TIME_FIELD_NUMBER;
      hash = (53 * hash) + getLastConfigAckTime().hashCode();
    }
    if (hasLastConfigSendTime()) {
      hash = (37 * hash) + LAST_CONFIG_SEND_TIME_FIELD_NUMBER;
      hash = (53 * hash) + getLastConfigSendTime().hashCode();
    }
    hash = (37 * hash) + BLOCKED_FIELD_NUMBER;
    hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getBlocked());
    if (hasLastErrorTime()) {
      hash = (37 * hash) + LAST_ERROR_TIME_FIELD_NUMBER;
      hash = (53 * hash) + getLastErrorTime().hashCode();
    }
    if (hasLastErrorStatus()) {
      hash = (37 * hash) + LAST_ERROR_STATUS_FIELD_NUMBER;
      hash = (53 * hash) + getLastErrorStatus().hashCode();
    }
    if (hasConfig()) {
      hash = (37 * hash) + CONFIG_FIELD_NUMBER;
      hash = (53 * hash) + getConfig().hashCode();
    }
    if (hasState()) {
      hash = (37 * hash) + STATE_FIELD_NUMBER;
      hash = (53 * hash) + getState().hashCode();
    }
    hash = (37 * hash) + LOG_LEVEL_FIELD_NUMBER;
    hash = (53 * hash) + logLevel_;
    if (!internalGetMetadata().getMap().isEmpty()) {
      hash = (37 * hash) + METADATA_FIELD_NUMBER;
      hash = (53 * hash) + internalGetMetadata().hashCode();
    }
    if (hasGatewayConfig()) {
      hash = (37 * hash) + GATEWAY_CONFIG_FIELD_NUMBER;
      hash = (53 * hash) + getGatewayConfig().hashCode();
    }
    hash = (29 * hash) + getUnknownFields().hashCode();
    memoizedHashCode = hash;
    return hash;
  }

  public static com.google.cloud.iot.v1.Device parseFrom(java.nio.ByteBuffer data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

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

  public static com.google.cloud.iot.v1.Device parseFrom(com.google.protobuf.ByteString data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

  public static com.google.cloud.iot.v1.Device parseFrom(
      com.google.protobuf.ByteString data,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }

  public static com.google.cloud.iot.v1.Device parseFrom(byte[] data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

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

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

  public static com.google.cloud.iot.v1.Device parseFrom(
      java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseWithIOException(
        PARSER, input, extensionRegistry);
  }

  public static com.google.cloud.iot.v1.Device parseDelimitedFrom(java.io.InputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
  }

  public static com.google.cloud.iot.v1.Device parseDelimitedFrom(
      java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(
        PARSER, input, extensionRegistry);
  }

  public static com.google.cloud.iot.v1.Device parseFrom(com.google.protobuf.CodedInputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
  }

  public static com.google.cloud.iot.v1.Device parseFrom(
      com.google.protobuf.CodedInputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseWithIOException(
        PARSER, input, extensionRegistry);
  }

  @java.lang.Override
  public Builder newBuilderForType() {
    return newBuilder();
  }

  public static Builder newBuilder() {
    return DEFAULT_INSTANCE.toBuilder();
  }

  public static Builder newBuilder(com.google.cloud.iot.v1.Device prototype) {
    return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
  }

  @java.lang.Override
  public Builder toBuilder() {
    return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this);
  }

  @java.lang.Override
  protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
    Builder builder = new Builder(parent);
    return builder;
  }
  /**
   *
   *
   * <pre>
   * The device resource.
   * </pre>
   *
   * Protobuf type {@code google.cloud.iot.v1.Device}
   */
  public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
      implements
      // @@protoc_insertion_point(builder_implements:google.cloud.iot.v1.Device)
      com.google.cloud.iot.v1.DeviceOrBuilder {
    public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
      return com.google.cloud.iot.v1.ResourcesProto
          .internal_static_google_cloud_iot_v1_Device_descriptor;
    }

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

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

    @java.lang.Override
    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
        internalGetFieldAccessorTable() {
      return com.google.cloud.iot.v1.ResourcesProto
          .internal_static_google_cloud_iot_v1_Device_fieldAccessorTable
          .ensureFieldAccessorsInitialized(
              com.google.cloud.iot.v1.Device.class, com.google.cloud.iot.v1.Device.Builder.class);
    }

    // Construct using com.google.cloud.iot.v1.Device.newBuilder()
    private Builder() {}

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

    @java.lang.Override
    public Builder clear() {
      super.clear();
      bitField0_ = 0;
      id_ = "";
      name_ = "";
      numId_ = 0L;
      if (credentialsBuilder_ == null) {
        credentials_ = java.util.Collections.emptyList();
      } else {
        credentials_ = null;
        credentialsBuilder_.clear();
      }
      bitField0_ = (bitField0_ & ~0x00000008);
      lastHeartbeatTime_ = null;
      if (lastHeartbeatTimeBuilder_ != null) {
        lastHeartbeatTimeBuilder_.dispose();
        lastHeartbeatTimeBuilder_ = null;
      }
      lastEventTime_ = null;
      if (lastEventTimeBuilder_ != null) {
        lastEventTimeBuilder_.dispose();
        lastEventTimeBuilder_ = null;
      }
      lastStateTime_ = null;
      if (lastStateTimeBuilder_ != null) {
        lastStateTimeBuilder_.dispose();
        lastStateTimeBuilder_ = null;
      }
      lastConfigAckTime_ = null;
      if (lastConfigAckTimeBuilder_ != null) {
        lastConfigAckTimeBuilder_.dispose();
        lastConfigAckTimeBuilder_ = null;
      }
      lastConfigSendTime_ = null;
      if (lastConfigSendTimeBuilder_ != null) {
        lastConfigSendTimeBuilder_.dispose();
        lastConfigSendTimeBuilder_ = null;
      }
      blocked_ = false;
      lastErrorTime_ = null;
      if (lastErrorTimeBuilder_ != null) {
        lastErrorTimeBuilder_.dispose();
        lastErrorTimeBuilder_ = null;
      }
      lastErrorStatus_ = null;
      if (lastErrorStatusBuilder_ != null) {
        lastErrorStatusBuilder_.dispose();
        lastErrorStatusBuilder_ = null;
      }
      config_ = null;
      if (configBuilder_ != null) {
        configBuilder_.dispose();
        configBuilder_ = null;
      }
      state_ = null;
      if (stateBuilder_ != null) {
        stateBuilder_.dispose();
        stateBuilder_ = null;
      }
      logLevel_ = 0;
      internalGetMutableMetadata().clear();
      gatewayConfig_ = null;
      if (gatewayConfigBuilder_ != null) {
        gatewayConfigBuilder_.dispose();
        gatewayConfigBuilder_ = null;
      }
      return this;
    }

    @java.lang.Override
    public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
      return com.google.cloud.iot.v1.ResourcesProto
          .internal_static_google_cloud_iot_v1_Device_descriptor;
    }

    @java.lang.Override
    public com.google.cloud.iot.v1.Device getDefaultInstanceForType() {
      return com.google.cloud.iot.v1.Device.getDefaultInstance();
    }

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

    @java.lang.Override
    public com.google.cloud.iot.v1.Device buildPartial() {
      com.google.cloud.iot.v1.Device result = new com.google.cloud.iot.v1.Device(this);
      buildPartialRepeatedFields(result);
      if (bitField0_ != 0) {
        buildPartial0(result);
      }
      onBuilt();
      return result;
    }

    private void buildPartialRepeatedFields(com.google.cloud.iot.v1.Device result) {
      if (credentialsBuilder_ == null) {
        if (((bitField0_ & 0x00000008) != 0)) {
          credentials_ = java.util.Collections.unmodifiableList(credentials_);
          bitField0_ = (bitField0_ & ~0x00000008);
        }
        result.credentials_ = credentials_;
      } else {
        result.credentials_ = credentialsBuilder_.build();
      }
    }

    private void buildPartial0(com.google.cloud.iot.v1.Device result) {
      int from_bitField0_ = bitField0_;
      if (((from_bitField0_ & 0x00000001) != 0)) {
        result.id_ = id_;
      }
      if (((from_bitField0_ & 0x00000002) != 0)) {
        result.name_ = name_;
      }
      if (((from_bitField0_ & 0x00000004) != 0)) {
        result.numId_ = numId_;
      }
      if (((from_bitField0_ & 0x00000010) != 0)) {
        result.lastHeartbeatTime_ =
            lastHeartbeatTimeBuilder_ == null
                ? lastHeartbeatTime_
                : lastHeartbeatTimeBuilder_.build();
      }
      if (((from_bitField0_ & 0x00000020) != 0)) {
        result.lastEventTime_ =
            lastEventTimeBuilder_ == null ? lastEventTime_ : lastEventTimeBuilder_.build();
      }
      if (((from_bitField0_ & 0x00000040) != 0)) {
        result.lastStateTime_ =
            lastStateTimeBuilder_ == null ? lastStateTime_ : lastStateTimeBuilder_.build();
      }
      if (((from_bitField0_ & 0x00000080) != 0)) {
        result.lastConfigAckTime_ =
            lastConfigAckTimeBuilder_ == null
                ? lastConfigAckTime_
                : lastConfigAckTimeBuilder_.build();
      }
      if (((from_bitField0_ & 0x00000100) != 0)) {
        result.lastConfigSendTime_ =
            lastConfigSendTimeBuilder_ == null
                ? lastConfigSendTime_
                : lastConfigSendTimeBuilder_.build();
      }
      if (((from_bitField0_ & 0x00000200) != 0)) {
        result.blocked_ = blocked_;
      }
      if (((from_bitField0_ & 0x00000400) != 0)) {
        result.lastErrorTime_ =
            lastErrorTimeBuilder_ == null ? lastErrorTime_ : lastErrorTimeBuilder_.build();
      }
      if (((from_bitField0_ & 0x00000800) != 0)) {
        result.lastErrorStatus_ =
            lastErrorStatusBuilder_ == null ? lastErrorStatus_ : lastErrorStatusBuilder_.build();
      }
      if (((from_bitField0_ & 0x00001000) != 0)) {
        result.config_ = configBuilder_ == null ? config_ : configBuilder_.build();
      }
      if (((from_bitField0_ & 0x00002000) != 0)) {
        result.state_ = stateBuilder_ == null ? state_ : stateBuilder_.build();
      }
      if (((from_bitField0_ & 0x00004000) != 0)) {
        result.logLevel_ = logLevel_;
      }
      if (((from_bitField0_ & 0x00008000) != 0)) {
        result.metadata_ = internalGetMetadata();
        result.metadata_.makeImmutable();
      }
      if (((from_bitField0_ & 0x00010000) != 0)) {
        result.gatewayConfig_ =
            gatewayConfigBuilder_ == null ? gatewayConfig_ : gatewayConfigBuilder_.build();
      }
    }

    @java.lang.Override
    public Builder clone() {
      return super.clone();
    }

    @java.lang.Override
    public Builder setField(
        com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) {
      return super.setField(field, value);
    }

    @java.lang.Override
    public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) {
      return super.clearField(field);
    }

    @java.lang.Override
    public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) {
      return super.clearOneof(oneof);
    }

    @java.lang.Override
    public Builder setRepeatedField(
        com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) {
      return super.setRepeatedField(field, index, value);
    }

    @java.lang.Override
    public Builder addRepeatedField(
        com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) {
      return super.addRepeatedField(field, value);
    }

    @java.lang.Override
    public Builder mergeFrom(com.google.protobuf.Message other) {
      if (other instanceof com.google.cloud.iot.v1.Device) {
        return mergeFrom((com.google.cloud.iot.v1.Device) other);
      } else {
        super.mergeFrom(other);
        return this;
      }
    }

    public Builder mergeFrom(com.google.cloud.iot.v1.Device other) {
      if (other == com.google.cloud.iot.v1.Device.getDefaultInstance()) return this;
      if (!other.getId().isEmpty()) {
        id_ = other.id_;
        bitField0_ |= 0x00000001;
        onChanged();
      }
      if (!other.getName().isEmpty()) {
        name_ = other.name_;
        bitField0_ |= 0x00000002;
        onChanged();
      }
      if (other.getNumId() != 0L) {
        setNumId(other.getNumId());
      }
      if (credentialsBuilder_ == null) {
        if (!other.credentials_.isEmpty()) {
          if (credentials_.isEmpty()) {
            credentials_ = other.credentials_;
            bitField0_ = (bitField0_ & ~0x00000008);
          } else {
            ensureCredentialsIsMutable();
            credentials_.addAll(other.credentials_);
          }
          onChanged();
        }
      } else {
        if (!other.credentials_.isEmpty()) {
          if (credentialsBuilder_.isEmpty()) {
            credentialsBuilder_.dispose();
            credentialsBuilder_ = null;
            credentials_ = other.credentials_;
            bitField0_ = (bitField0_ & ~0x00000008);
            credentialsBuilder_ =
                com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders
                    ? getCredentialsFieldBuilder()
                    : null;
          } else {
            credentialsBuilder_.addAllMessages(other.credentials_);
          }
        }
      }
      if (other.hasLastHeartbeatTime()) {
        mergeLastHeartbeatTime(other.getLastHeartbeatTime());
      }
      if (other.hasLastEventTime()) {
        mergeLastEventTime(other.getLastEventTime());
      }
      if (other.hasLastStateTime()) {
        mergeLastStateTime(other.getLastStateTime());
      }
      if (other.hasLastConfigAckTime()) {
        mergeLastConfigAckTime(other.getLastConfigAckTime());
      }
      if (other.hasLastConfigSendTime()) {
        mergeLastConfigSendTime(other.getLastConfigSendTime());
      }
      if (other.getBlocked() != false) {
        setBlocked(other.getBlocked());
      }
      if (other.hasLastErrorTime()) {
        mergeLastErrorTime(other.getLastErrorTime());
      }
      if (other.hasLastErrorStatus()) {
        mergeLastErrorStatus(other.getLastErrorStatus());
      }
      if (other.hasConfig()) {
        mergeConfig(other.getConfig());
      }
      if (other.hasState()) {
        mergeState(other.getState());
      }
      if (other.logLevel_ != 0) {
        setLogLevelValue(other.getLogLevelValue());
      }
      internalGetMutableMetadata().mergeFrom(other.internalGetMetadata());
      bitField0_ |= 0x00008000;
      if (other.hasGatewayConfig()) {
        mergeGatewayConfig(other.getGatewayConfig());
      }
      this.mergeUnknownFields(other.getUnknownFields());
      onChanged();
      return this;
    }

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

    @java.lang.Override
    public Builder mergeFrom(
        com.google.protobuf.CodedInputStream input,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws java.io.IOException {
      if (extensionRegistry == null) {
        throw new java.lang.NullPointerException();
      }
      try {
        boolean done = false;
        while (!done) {
          int tag = input.readTag();
          switch (tag) {
            case 0:
              done = true;
              break;
            case 10:
              {
                id_ = input.readStringRequireUtf8();
                bitField0_ |= 0x00000001;
                break;
              } // case 10
            case 18:
              {
                name_ = input.readStringRequireUtf8();
                bitField0_ |= 0x00000002;
                break;
              } // case 18
            case 24:
              {
                numId_ = input.readUInt64();
                bitField0_ |= 0x00000004;
                break;
              } // case 24
            case 58:
              {
                input.readMessage(
                    getLastHeartbeatTimeFieldBuilder().getBuilder(), extensionRegistry);
                bitField0_ |= 0x00000010;
                break;
              } // case 58
            case 66:
              {
                input.readMessage(getLastEventTimeFieldBuilder().getBuilder(), extensionRegistry);
                bitField0_ |= 0x00000020;
                break;
              } // case 66
            case 82:
              {
                input.readMessage(getLastErrorTimeFieldBuilder().getBuilder(), extensionRegistry);
                bitField0_ |= 0x00000400;
                break;
              } // case 82
            case 90:
              {
                input.readMessage(getLastErrorStatusFieldBuilder().getBuilder(), extensionRegistry);
                bitField0_ |= 0x00000800;
                break;
              } // case 90
            case 98:
              {
                com.google.cloud.iot.v1.DeviceCredential m =
                    input.readMessage(
                        com.google.cloud.iot.v1.DeviceCredential.parser(), extensionRegistry);
                if (credentialsBuilder_ == null) {
                  ensureCredentialsIsMutable();
                  credentials_.add(m);
                } else {
                  credentialsBuilder_.addMessage(m);
                }
                break;
              } // case 98
            case 106:
              {
                input.readMessage(getConfigFieldBuilder().getBuilder(), extensionRegistry);
                bitField0_ |= 0x00001000;
                break;
              } // case 106
            case 114:
              {
                input.readMessage(
                    getLastConfigAckTimeFieldBuilder().getBuilder(), extensionRegistry);
                bitField0_ |= 0x00000080;
                break;
              } // case 114
            case 130:
              {
                input.readMessage(getStateFieldBuilder().getBuilder(), extensionRegistry);
                bitField0_ |= 0x00002000;
                break;
              } // case 130
            case 138:
              {
                com.google.protobuf.MapEntry<java.lang.String, java.lang.String> metadata__ =
                    input.readMessage(
                        MetadataDefaultEntryHolder.defaultEntry.getParserForType(),
                        extensionRegistry);
                internalGetMutableMetadata()
                    .getMutableMap()
                    .put(metadata__.getKey(), metadata__.getValue());
                bitField0_ |= 0x00008000;
                break;
              } // case 138
            case 146:
              {
                input.readMessage(
                    getLastConfigSendTimeFieldBuilder().getBuilder(), extensionRegistry);
                bitField0_ |= 0x00000100;
                break;
              } // case 146
            case 152:
              {
                blocked_ = input.readBool();
                bitField0_ |= 0x00000200;
                break;
              } // case 152
            case 162:
              {
                input.readMessage(getLastStateTimeFieldBuilder().getBuilder(), extensionRegistry);
                bitField0_ |= 0x00000040;
                break;
              } // case 162
            case 168:
              {
                logLevel_ = input.readEnum();
                bitField0_ |= 0x00004000;
                break;
              } // case 168
            case 194:
              {
                input.readMessage(getGatewayConfigFieldBuilder().getBuilder(), extensionRegistry);
                bitField0_ |= 0x00010000;
                break;
              } // case 194
            default:
              {
                if (!super.parseUnknownField(input, extensionRegistry, tag)) {
                  done = true; // was an endgroup tag
                }
                break;
              } // default:
          } // switch (tag)
        } // while (!done)
      } catch (com.google.protobuf.InvalidProtocolBufferException e) {
        throw e.unwrapIOException();
      } finally {
        onChanged();
      } // finally
      return this;
    }

    private int bitField0_;

    private java.lang.Object id_ = "";
    /**
     *
     *
     * <pre>
     * The user-defined device identifier. The device ID must be unique
     * within a device registry.
     * </pre>
     *
     * <code>string id = 1;</code>
     *
     * @return The id.
     */
    public java.lang.String getId() {
      java.lang.Object ref = id_;
      if (!(ref instanceof java.lang.String)) {
        com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
        java.lang.String s = bs.toStringUtf8();
        id_ = s;
        return s;
      } else {
        return (java.lang.String) ref;
      }
    }
    /**
     *
     *
     * <pre>
     * The user-defined device identifier. The device ID must be unique
     * within a device registry.
     * </pre>
     *
     * <code>string id = 1;</code>
     *
     * @return The bytes for id.
     */
    public com.google.protobuf.ByteString getIdBytes() {
      java.lang.Object ref = id_;
      if (ref instanceof String) {
        com.google.protobuf.ByteString b =
            com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
        id_ = b;
        return b;
      } else {
        return (com.google.protobuf.ByteString) ref;
      }
    }
    /**
     *
     *
     * <pre>
     * The user-defined device identifier. The device ID must be unique
     * within a device registry.
     * </pre>
     *
     * <code>string id = 1;</code>
     *
     * @param value The id to set.
     * @return This builder for chaining.
     */
    public Builder setId(java.lang.String value) {
      if (value == null) {
        throw new NullPointerException();
      }
      id_ = value;
      bitField0_ |= 0x00000001;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * The user-defined device identifier. The device ID must be unique
     * within a device registry.
     * </pre>
     *
     * <code>string id = 1;</code>
     *
     * @return This builder for chaining.
     */
    public Builder clearId() {
      id_ = getDefaultInstance().getId();
      bitField0_ = (bitField0_ & ~0x00000001);
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * The user-defined device identifier. The device ID must be unique
     * within a device registry.
     * </pre>
     *
     * <code>string id = 1;</code>
     *
     * @param value The bytes for id to set.
     * @return This builder for chaining.
     */
    public Builder setIdBytes(com.google.protobuf.ByteString value) {
      if (value == null) {
        throw new NullPointerException();
      }
      checkByteStringIsUtf8(value);
      id_ = value;
      bitField0_ |= 0x00000001;
      onChanged();
      return this;
    }

    private java.lang.Object name_ = "";
    /**
     *
     *
     * <pre>
     * The resource path name. For example,
     * `projects/p1/locations/us-central1/registries/registry0/devices/dev0` or
     * `projects/p1/locations/us-central1/registries/registry0/devices/{num_id}`.
     * When `name` is populated as a response from the service, it always ends
     * in the device numeric ID.
     * </pre>
     *
     * <code>string name = 2;</code>
     *
     * @return The name.
     */
    public java.lang.String getName() {
      java.lang.Object ref = name_;
      if (!(ref instanceof java.lang.String)) {
        com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
        java.lang.String s = bs.toStringUtf8();
        name_ = s;
        return s;
      } else {
        return (java.lang.String) ref;
      }
    }
    /**
     *
     *
     * <pre>
     * The resource path name. For example,
     * `projects/p1/locations/us-central1/registries/registry0/devices/dev0` or
     * `projects/p1/locations/us-central1/registries/registry0/devices/{num_id}`.
     * When `name` is populated as a response from the service, it always ends
     * in the device numeric ID.
     * </pre>
     *
     * <code>string name = 2;</code>
     *
     * @return The bytes for name.
     */
    public com.google.protobuf.ByteString getNameBytes() {
      java.lang.Object ref = name_;
      if (ref instanceof String) {
        com.google.protobuf.ByteString b =
            com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
        name_ = b;
        return b;
      } else {
        return (com.google.protobuf.ByteString) ref;
      }
    }
    /**
     *
     *
     * <pre>
     * The resource path name. For example,
     * `projects/p1/locations/us-central1/registries/registry0/devices/dev0` or
     * `projects/p1/locations/us-central1/registries/registry0/devices/{num_id}`.
     * When `name` is populated as a response from the service, it always ends
     * in the device numeric ID.
     * </pre>
     *
     * <code>string name = 2;</code>
     *
     * @param value The name to set.
     * @return This builder for chaining.
     */
    public Builder setName(java.lang.String value) {
      if (value == null) {
        throw new NullPointerException();
      }
      name_ = value;
      bitField0_ |= 0x00000002;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * The resource path name. For example,
     * `projects/p1/locations/us-central1/registries/registry0/devices/dev0` or
     * `projects/p1/locations/us-central1/registries/registry0/devices/{num_id}`.
     * When `name` is populated as a response from the service, it always ends
     * in the device numeric ID.
     * </pre>
     *
     * <code>string name = 2;</code>
     *
     * @return This builder for chaining.
     */
    public Builder clearName() {
      name_ = getDefaultInstance().getName();
      bitField0_ = (bitField0_ & ~0x00000002);
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * The resource path name. For example,
     * `projects/p1/locations/us-central1/registries/registry0/devices/dev0` or
     * `projects/p1/locations/us-central1/registries/registry0/devices/{num_id}`.
     * When `name` is populated as a response from the service, it always ends
     * in the device numeric ID.
     * </pre>
     *
     * <code>string name = 2;</code>
     *
     * @param value The bytes for name to set.
     * @return This builder for chaining.
     */
    public Builder setNameBytes(com.google.protobuf.ByteString value) {
      if (value == null) {
        throw new NullPointerException();
      }
      checkByteStringIsUtf8(value);
      name_ = value;
      bitField0_ |= 0x00000002;
      onChanged();
      return this;
    }

    private long numId_;
    /**
     *
     *
     * <pre>
     * [Output only] A server-defined unique numeric ID for the device. This is a
     * more compact way to identify devices, and it is globally unique.
     * </pre>
     *
     * <code>uint64 num_id = 3;</code>
     *
     * @return The numId.
     */
    @java.lang.Override
    public long getNumId() {
      return numId_;
    }
    /**
     *
     *
     * <pre>
     * [Output only] A server-defined unique numeric ID for the device. This is a
     * more compact way to identify devices, and it is globally unique.
     * </pre>
     *
     * <code>uint64 num_id = 3;</code>
     *
     * @param value The numId to set.
     * @return This builder for chaining.
     */
    public Builder setNumId(long value) {

      numId_ = value;
      bitField0_ |= 0x00000004;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * [Output only] A server-defined unique numeric ID for the device. This is a
     * more compact way to identify devices, and it is globally unique.
     * </pre>
     *
     * <code>uint64 num_id = 3;</code>
     *
     * @return This builder for chaining.
     */
    public Builder clearNumId() {
      bitField0_ = (bitField0_ & ~0x00000004);
      numId_ = 0L;
      onChanged();
      return this;
    }

    private java.util.List<com.google.cloud.iot.v1.DeviceCredential> credentials_ =
        java.util.Collections.emptyList();

    private void ensureCredentialsIsMutable() {
      if (!((bitField0_ & 0x00000008) != 0)) {
        credentials_ =
            new java.util.ArrayList<com.google.cloud.iot.v1.DeviceCredential>(credentials_);
        bitField0_ |= 0x00000008;
      }
    }

    private com.google.protobuf.RepeatedFieldBuilderV3<
            com.google.cloud.iot.v1.DeviceCredential,
            com.google.cloud.iot.v1.DeviceCredential.Builder,
            com.google.cloud.iot.v1.DeviceCredentialOrBuilder>
        credentialsBuilder_;

    /**
     *
     *
     * <pre>
     * The credentials used to authenticate this device. To allow credential
     * rotation without interruption, multiple device credentials can be bound to
     * this device. No more than 3 credentials can be bound to a single device at
     * a time. When new credentials are added to a device, they are verified
     * against the registry credentials. For details, see the description of the
     * `DeviceRegistry.credentials` field.
     * </pre>
     *
     * <code>repeated .google.cloud.iot.v1.DeviceCredential credentials = 12;</code>
     */
    public java.util.List<com.google.cloud.iot.v1.DeviceCredential> getCredentialsList() {
      if (credentialsBuilder_ == null) {
        return java.util.Collections.unmodifiableList(credentials_);
      } else {
        return credentialsBuilder_.getMessageList();
      }
    }
    /**
     *
     *
     * <pre>
     * The credentials used to authenticate this device. To allow credential
     * rotation without interruption, multiple device credentials can be bound to
     * this device. No more than 3 credentials can be bound to a single device at
     * a time. When new credentials are added to a device, they are verified
     * against the registry credentials. For details, see the description of the
     * `DeviceRegistry.credentials` field.
     * </pre>
     *
     * <code>repeated .google.cloud.iot.v1.DeviceCredential credentials = 12;</code>
     */
    public int getCredentialsCount() {
      if (credentialsBuilder_ == null) {
        return credentials_.size();
      } else {
        return credentialsBuilder_.getCount();
      }
    }
    /**
     *
     *
     * <pre>
     * The credentials used to authenticate this device. To allow credential
     * rotation without interruption, multiple device credentials can be bound to
     * this device. No more than 3 credentials can be bound to a single device at
     * a time. When new credentials are added to a device, they are verified
     * against the registry credentials. For details, see the description of the
     * `DeviceRegistry.credentials` field.
     * </pre>
     *
     * <code>repeated .google.cloud.iot.v1.DeviceCredential credentials = 12;</code>
     */
    public com.google.cloud.iot.v1.DeviceCredential getCredentials(int index) {
      if (credentialsBuilder_ == null) {
        return credentials_.get(index);
      } else {
        return credentialsBuilder_.getMessage(index);
      }
    }
    /**
     *
     *
     * <pre>
     * The credentials used to authenticate this device. To allow credential
     * rotation without interruption, multiple device credentials can be bound to
     * this device. No more than 3 credentials can be bound to a single device at
     * a time. When new credentials are added to a device, they are verified
     * against the registry credentials. For details, see the description of the
     * `DeviceRegistry.credentials` field.
     * </pre>
     *
     * <code>repeated .google.cloud.iot.v1.DeviceCredential credentials = 12;</code>
     */
    public Builder setCredentials(int index, com.google.cloud.iot.v1.DeviceCredential value) {
      if (credentialsBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureCredentialsIsMutable();
        credentials_.set(index, value);
        onChanged();
      } else {
        credentialsBuilder_.setMessage(index, value);
      }
      return this;
    }
    /**
     *
     *
     * <pre>
     * The credentials used to authenticate this device. To allow credential
     * rotation without interruption, multiple device credentials can be bound to
     * this device. No more than 3 credentials can be bound to a single device at
     * a time. When new credentials are added to a device, they are verified
     * against the registry credentials. For details, see the description of the
     * `DeviceRegistry.credentials` field.
     * </pre>
     *
     * <code>repeated .google.cloud.iot.v1.DeviceCredential credentials = 12;</code>
     */
    public Builder setCredentials(
        int index, com.google.cloud.iot.v1.DeviceCredential.Builder builderForValue) {
      if (credentialsBuilder_ == null) {
        ensureCredentialsIsMutable();
        credentials_.set(index, builderForValue.build());
        onChanged();
      } else {
        credentialsBuilder_.setMessage(index, builderForValue.build());
      }
      return this;
    }
    /**
     *
     *
     * <pre>
     * The credentials used to authenticate this device. To allow credential
     * rotation without interruption, multiple device credentials can be bound to
     * this device. No more than 3 credentials can be bound to a single device at
     * a time. When new credentials are added to a device, they are verified
     * against the registry credentials. For details, see the description of the
     * `DeviceRegistry.credentials` field.
     * </pre>
     *
     * <code>repeated .google.cloud.iot.v1.DeviceCredential credentials = 12;</code>
     */
    public Builder addCredentials(com.google.cloud.iot.v1.DeviceCredential value) {
      if (credentialsBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureCredentialsIsMutable();
        credentials_.add(value);
        onChanged();
      } else {
        credentialsBuilder_.addMessage(value);
      }
      return this;
    }
    /**
     *
     *
     * <pre>
     * The credentials used to authenticate this device. To allow credential
     * rotation without interruption, multiple device credentials can be bound to
     * this device. No more than 3 credentials can be bound to a single device at
     * a time. When new credentials are added to a device, they are verified
     * against the registry credentials. For details, see the description of the
     * `DeviceRegistry.credentials` field.
     * </pre>
     *
     * <code>repeated .google.cloud.iot.v1.DeviceCredential credentials = 12;</code>
     */
    public Builder addCredentials(int index, com.google.cloud.iot.v1.DeviceCredential value) {
      if (credentialsBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureCredentialsIsMutable();
        credentials_.add(index, value);
        onChanged();
      } else {
        credentialsBuilder_.addMessage(index, value);
      }
      return this;
    }
    /**
     *
     *
     * <pre>
     * The credentials used to authenticate this device. To allow credential
     * rotation without interruption, multiple device credentials can be bound to
     * this device. No more than 3 credentials can be bound to a single device at
     * a time. When new credentials are added to a device, they are verified
     * against the registry credentials. For details, see the description of the
     * `DeviceRegistry.credentials` field.
     * </pre>
     *
     * <code>repeated .google.cloud.iot.v1.DeviceCredential credentials = 12;</code>
     */
    public Builder addCredentials(
        com.google.cloud.iot.v1.DeviceCredential.Builder builderForValue) {
      if (credentialsBuilder_ == null) {
        ensureCredentialsIsMutable();
        credentials_.add(builderForValue.build());
        onChanged();
      } else {
        credentialsBuilder_.addMessage(builderForValue.build());
      }
      return this;
    }
    /**
     *
     *
     * <pre>
     * The credentials used to authenticate this device. To allow credential
     * rotation without interruption, multiple device credentials can be bound to
     * this device. No more than 3 credentials can be bound to a single device at
     * a time. When new credentials are added to a device, they are verified
     * against the registry credentials. For details, see the description of the
     * `DeviceRegistry.credentials` field.
     * </pre>
     *
     * <code>repeated .google.cloud.iot.v1.DeviceCredential credentials = 12;</code>
     */
    public Builder addCredentials(
        int index, com.google.cloud.iot.v1.DeviceCredential.Builder builderForValue) {
      if (credentialsBuilder_ == null) {
        ensureCredentialsIsMutable();
        credentials_.add(index, builderForValue.build());
        onChanged();
      } else {
        credentialsBuilder_.addMessage(index, builderForValue.build());
      }
      return this;
    }
    /**
     *
     *
     * <pre>
     * The credentials used to authenticate this device. To allow credential
     * rotation without interruption, multiple device credentials can be bound to
     * this device. No more than 3 credentials can be bound to a single device at
     * a time. When new credentials are added to a device, they are verified
     * against the registry credentials. For details, see the description of the
     * `DeviceRegistry.credentials` field.
     * </pre>
     *
     * <code>repeated .google.cloud.iot.v1.DeviceCredential credentials = 12;</code>
     */
    public Builder addAllCredentials(
        java.lang.Iterable<? extends com.google.cloud.iot.v1.DeviceCredential> values) {
      if (credentialsBuilder_ == null) {
        ensureCredentialsIsMutable();
        com.google.protobuf.AbstractMessageLite.Builder.addAll(values, credentials_);
        onChanged();
      } else {
        credentialsBuilder_.addAllMessages(values);
      }
      return this;
    }
    /**
     *
     *
     * <pre>
     * The credentials used to authenticate this device. To allow credential
     * rotation without interruption, multiple device credentials can be bound to
     * this device. No more than 3 credentials can be bound to a single device at
     * a time. When new credentials are added to a device, they are verified
     * against the registry credentials. For details, see the description of the
     * `DeviceRegistry.credentials` field.
     * </pre>
     *
     * <code>repeated .google.cloud.iot.v1.DeviceCredential credentials = 12;</code>
     */
    public Builder clearCredentials() {
      if (credentialsBuilder_ == null) {
        credentials_ = java.util.Collections.emptyList();
        bitField0_ = (bitField0_ & ~0x00000008);
        onChanged();
      } else {
        credentialsBuilder_.clear();
      }
      return this;
    }
    /**
     *
     *
     * <pre>
     * The credentials used to authenticate this device. To allow credential
     * rotation without interruption, multiple device credentials can be bound to
     * this device. No more than 3 credentials can be bound to a single device at
     * a time. When new credentials are added to a device, they are verified
     * against the registry credentials. For details, see the description of the
     * `DeviceRegistry.credentials` field.
     * </pre>
     *
     * <code>repeated .google.cloud.iot.v1.DeviceCredential credentials = 12;</code>
     */
    public Builder removeCredentials(int index) {
      if (credentialsBuilder_ == null) {
        ensureCredentialsIsMutable();
        credentials_.remove(index);
        onChanged();
      } else {
        credentialsBuilder_.remove(index);
      }
      return this;
    }
    /**
     *
     *
     * <pre>
     * The credentials used to authenticate this device. To allow credential
     * rotation without interruption, multiple device credentials can be bound to
     * this device. No more than 3 credentials can be bound to a single device at
     * a time. When new credentials are added to a device, they are verified
     * against the registry credentials. For details, see the description of the
     * `DeviceRegistry.credentials` field.
     * </pre>
     *
     * <code>repeated .google.cloud.iot.v1.DeviceCredential credentials = 12;</code>
     */
    public com.google.cloud.iot.v1.DeviceCredential.Builder getCredentialsBuilder(int index) {
      return getCredentialsFieldBuilder().getBuilder(index);
    }
    /**
     *
     *
     * <pre>
     * The credentials used to authenticate this device. To allow credential
     * rotation without interruption, multiple device credentials can be bound to
     * this device. No more than 3 credentials can be bound to a single device at
     * a time. When new credentials are added to a device, they are verified
     * against the registry credentials. For details, see the description of the
     * `DeviceRegistry.credentials` field.
     * </pre>
     *
     * <code>repeated .google.cloud.iot.v1.DeviceCredential credentials = 12;</code>
     */
    public com.google.cloud.iot.v1.DeviceCredentialOrBuilder getCredentialsOrBuilder(int index) {
      if (credentialsBuilder_ == null) {
        return credentials_.get(index);
      } else {
        return credentialsBuilder_.getMessageOrBuilder(index);
      }
    }
    /**
     *
     *
     * <pre>
     * The credentials used to authenticate this device. To allow credential
     * rotation without interruption, multiple device credentials can be bound to
     * this device. No more than 3 credentials can be bound to a single device at
     * a time. When new credentials are added to a device, they are verified
     * against the registry credentials. For details, see the description of the
     * `DeviceRegistry.credentials` field.
     * </pre>
     *
     * <code>repeated .google.cloud.iot.v1.DeviceCredential credentials = 12;</code>
     */
    public java.util.List<? extends com.google.cloud.iot.v1.DeviceCredentialOrBuilder>
        getCredentialsOrBuilderList() {
      if (credentialsBuilder_ != null) {
        return credentialsBuilder_.getMessageOrBuilderList();
      } else {
        return java.util.Collections.unmodifiableList(credentials_);
      }
    }
    /**
     *
     *
     * <pre>
     * The credentials used to authenticate this device. To allow credential
     * rotation without interruption, multiple device credentials can be bound to
     * this device. No more than 3 credentials can be bound to a single device at
     * a time. When new credentials are added to a device, they are verified
     * against the registry credentials. For details, see the description of the
     * `DeviceRegistry.credentials` field.
     * </pre>
     *
     * <code>repeated .google.cloud.iot.v1.DeviceCredential credentials = 12;</code>
     */
    public com.google.cloud.iot.v1.DeviceCredential.Builder addCredentialsBuilder() {
      return getCredentialsFieldBuilder()
          .addBuilder(com.google.cloud.iot.v1.DeviceCredential.getDefaultInstance());
    }
    /**
     *
     *
     * <pre>
     * The credentials used to authenticate this device. To allow credential
     * rotation without interruption, multiple device credentials can be bound to
     * this device. No more than 3 credentials can be bound to a single device at
     * a time. When new credentials are added to a device, they are verified
     * against the registry credentials. For details, see the description of the
     * `DeviceRegistry.credentials` field.
     * </pre>
     *
     * <code>repeated .google.cloud.iot.v1.DeviceCredential credentials = 12;</code>
     */
    public com.google.cloud.iot.v1.DeviceCredential.Builder addCredentialsBuilder(int index) {
      return getCredentialsFieldBuilder()
          .addBuilder(index, com.google.cloud.iot.v1.DeviceCredential.getDefaultInstance());
    }
    /**
     *
     *
     * <pre>
     * The credentials used to authenticate this device. To allow credential
     * rotation without interruption, multiple device credentials can be bound to
     * this device. No more than 3 credentials can be bound to a single device at
     * a time. When new credentials are added to a device, they are verified
     * against the registry credentials. For details, see the description of the
     * `DeviceRegistry.credentials` field.
     * </pre>
     *
     * <code>repeated .google.cloud.iot.v1.DeviceCredential credentials = 12;</code>
     */
    public java.util.List<com.google.cloud.iot.v1.DeviceCredential.Builder>
        getCredentialsBuilderList() {
      return getCredentialsFieldBuilder().getBuilderList();
    }

    private com.google.protobuf.RepeatedFieldBuilderV3<
            com.google.cloud.iot.v1.DeviceCredential,
            com.google.cloud.iot.v1.DeviceCredential.Builder,
            com.google.cloud.iot.v1.DeviceCredentialOrBuilder>
        getCredentialsFieldBuilder() {
      if (credentialsBuilder_ == null) {
        credentialsBuilder_ =
            new com.google.protobuf.RepeatedFieldBuilderV3<
                com.google.cloud.iot.v1.DeviceCredential,
                com.google.cloud.iot.v1.DeviceCredential.Builder,
                com.google.cloud.iot.v1.DeviceCredentialOrBuilder>(
                credentials_, ((bitField0_ & 0x00000008) != 0), getParentForChildren(), isClean());
        credentials_ = null;
      }
      return credentialsBuilder_;
    }

    private com.google.protobuf.Timestamp lastHeartbeatTime_;
    private com.google.protobuf.SingleFieldBuilderV3<
            com.google.protobuf.Timestamp,
            com.google.protobuf.Timestamp.Builder,
            com.google.protobuf.TimestampOrBuilder>
        lastHeartbeatTimeBuilder_;
    /**
     *
     *
     * <pre>
     * [Output only] The last time an MQTT `PINGREQ` was received. This field
     * applies only to devices connecting through MQTT. MQTT clients usually only
     * send `PINGREQ` messages if the connection is idle, and no other messages
     * have been sent. Timestamps are periodically collected and written to
     * storage; they may be stale by a few minutes.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_heartbeat_time = 7;</code>
     *
     * @return Whether the lastHeartbeatTime field is set.
     */
    public boolean hasLastHeartbeatTime() {
      return ((bitField0_ & 0x00000010) != 0);
    }
    /**
     *
     *
     * <pre>
     * [Output only] The last time an MQTT `PINGREQ` was received. This field
     * applies only to devices connecting through MQTT. MQTT clients usually only
     * send `PINGREQ` messages if the connection is idle, and no other messages
     * have been sent. Timestamps are periodically collected and written to
     * storage; they may be stale by a few minutes.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_heartbeat_time = 7;</code>
     *
     * @return The lastHeartbeatTime.
     */
    public com.google.protobuf.Timestamp getLastHeartbeatTime() {
      if (lastHeartbeatTimeBuilder_ == null) {
        return lastHeartbeatTime_ == null
            ? com.google.protobuf.Timestamp.getDefaultInstance()
            : lastHeartbeatTime_;
      } else {
        return lastHeartbeatTimeBuilder_.getMessage();
      }
    }
    /**
     *
     *
     * <pre>
     * [Output only] The last time an MQTT `PINGREQ` was received. This field
     * applies only to devices connecting through MQTT. MQTT clients usually only
     * send `PINGREQ` messages if the connection is idle, and no other messages
     * have been sent. Timestamps are periodically collected and written to
     * storage; they may be stale by a few minutes.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_heartbeat_time = 7;</code>
     */
    public Builder setLastHeartbeatTime(com.google.protobuf.Timestamp value) {
      if (lastHeartbeatTimeBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        lastHeartbeatTime_ = value;
      } else {
        lastHeartbeatTimeBuilder_.setMessage(value);
      }
      bitField0_ |= 0x00000010;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * [Output only] The last time an MQTT `PINGREQ` was received. This field
     * applies only to devices connecting through MQTT. MQTT clients usually only
     * send `PINGREQ` messages if the connection is idle, and no other messages
     * have been sent. Timestamps are periodically collected and written to
     * storage; they may be stale by a few minutes.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_heartbeat_time = 7;</code>
     */
    public Builder setLastHeartbeatTime(com.google.protobuf.Timestamp.Builder builderForValue) {
      if (lastHeartbeatTimeBuilder_ == null) {
        lastHeartbeatTime_ = builderForValue.build();
      } else {
        lastHeartbeatTimeBuilder_.setMessage(builderForValue.build());
      }
      bitField0_ |= 0x00000010;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * [Output only] The last time an MQTT `PINGREQ` was received. This field
     * applies only to devices connecting through MQTT. MQTT clients usually only
     * send `PINGREQ` messages if the connection is idle, and no other messages
     * have been sent. Timestamps are periodically collected and written to
     * storage; they may be stale by a few minutes.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_heartbeat_time = 7;</code>
     */
    public Builder mergeLastHeartbeatTime(com.google.protobuf.Timestamp value) {
      if (lastHeartbeatTimeBuilder_ == null) {
        if (((bitField0_ & 0x00000010) != 0)
            && lastHeartbeatTime_ != null
            && lastHeartbeatTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) {
          getLastHeartbeatTimeBuilder().mergeFrom(value);
        } else {
          lastHeartbeatTime_ = value;
        }
      } else {
        lastHeartbeatTimeBuilder_.mergeFrom(value);
      }
      bitField0_ |= 0x00000010;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * [Output only] The last time an MQTT `PINGREQ` was received. This field
     * applies only to devices connecting through MQTT. MQTT clients usually only
     * send `PINGREQ` messages if the connection is idle, and no other messages
     * have been sent. Timestamps are periodically collected and written to
     * storage; they may be stale by a few minutes.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_heartbeat_time = 7;</code>
     */
    public Builder clearLastHeartbeatTime() {
      bitField0_ = (bitField0_ & ~0x00000010);
      lastHeartbeatTime_ = null;
      if (lastHeartbeatTimeBuilder_ != null) {
        lastHeartbeatTimeBuilder_.dispose();
        lastHeartbeatTimeBuilder_ = null;
      }
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * [Output only] The last time an MQTT `PINGREQ` was received. This field
     * applies only to devices connecting through MQTT. MQTT clients usually only
     * send `PINGREQ` messages if the connection is idle, and no other messages
     * have been sent. Timestamps are periodically collected and written to
     * storage; they may be stale by a few minutes.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_heartbeat_time = 7;</code>
     */
    public com.google.protobuf.Timestamp.Builder getLastHeartbeatTimeBuilder() {
      bitField0_ |= 0x00000010;
      onChanged();
      return getLastHeartbeatTimeFieldBuilder().getBuilder();
    }
    /**
     *
     *
     * <pre>
     * [Output only] The last time an MQTT `PINGREQ` was received. This field
     * applies only to devices connecting through MQTT. MQTT clients usually only
     * send `PINGREQ` messages if the connection is idle, and no other messages
     * have been sent. Timestamps are periodically collected and written to
     * storage; they may be stale by a few minutes.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_heartbeat_time = 7;</code>
     */
    public com.google.protobuf.TimestampOrBuilder getLastHeartbeatTimeOrBuilder() {
      if (lastHeartbeatTimeBuilder_ != null) {
        return lastHeartbeatTimeBuilder_.getMessageOrBuilder();
      } else {
        return lastHeartbeatTime_ == null
            ? com.google.protobuf.Timestamp.getDefaultInstance()
            : lastHeartbeatTime_;
      }
    }
    /**
     *
     *
     * <pre>
     * [Output only] The last time an MQTT `PINGREQ` was received. This field
     * applies only to devices connecting through MQTT. MQTT clients usually only
     * send `PINGREQ` messages if the connection is idle, and no other messages
     * have been sent. Timestamps are periodically collected and written to
     * storage; they may be stale by a few minutes.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_heartbeat_time = 7;</code>
     */
    private com.google.protobuf.SingleFieldBuilderV3<
            com.google.protobuf.Timestamp,
            com.google.protobuf.Timestamp.Builder,
            com.google.protobuf.TimestampOrBuilder>
        getLastHeartbeatTimeFieldBuilder() {
      if (lastHeartbeatTimeBuilder_ == null) {
        lastHeartbeatTimeBuilder_ =
            new com.google.protobuf.SingleFieldBuilderV3<
                com.google.protobuf.Timestamp,
                com.google.protobuf.Timestamp.Builder,
                com.google.protobuf.TimestampOrBuilder>(
                getLastHeartbeatTime(), getParentForChildren(), isClean());
        lastHeartbeatTime_ = null;
      }
      return lastHeartbeatTimeBuilder_;
    }

    private com.google.protobuf.Timestamp lastEventTime_;
    private com.google.protobuf.SingleFieldBuilderV3<
            com.google.protobuf.Timestamp,
            com.google.protobuf.Timestamp.Builder,
            com.google.protobuf.TimestampOrBuilder>
        lastEventTimeBuilder_;
    /**
     *
     *
     * <pre>
     * [Output only] The last time a telemetry event was received. Timestamps are
     * periodically collected and written to storage; they may be stale by a few
     * minutes.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_event_time = 8;</code>
     *
     * @return Whether the lastEventTime field is set.
     */
    public boolean hasLastEventTime() {
      return ((bitField0_ & 0x00000020) != 0);
    }
    /**
     *
     *
     * <pre>
     * [Output only] The last time a telemetry event was received. Timestamps are
     * periodically collected and written to storage; they may be stale by a few
     * minutes.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_event_time = 8;</code>
     *
     * @return The lastEventTime.
     */
    public com.google.protobuf.Timestamp getLastEventTime() {
      if (lastEventTimeBuilder_ == null) {
        return lastEventTime_ == null
            ? com.google.protobuf.Timestamp.getDefaultInstance()
            : lastEventTime_;
      } else {
        return lastEventTimeBuilder_.getMessage();
      }
    }
    /**
     *
     *
     * <pre>
     * [Output only] The last time a telemetry event was received. Timestamps are
     * periodically collected and written to storage; they may be stale by a few
     * minutes.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_event_time = 8;</code>
     */
    public Builder setLastEventTime(com.google.protobuf.Timestamp value) {
      if (lastEventTimeBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        lastEventTime_ = value;
      } else {
        lastEventTimeBuilder_.setMessage(value);
      }
      bitField0_ |= 0x00000020;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * [Output only] The last time a telemetry event was received. Timestamps are
     * periodically collected and written to storage; they may be stale by a few
     * minutes.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_event_time = 8;</code>
     */
    public Builder setLastEventTime(com.google.protobuf.Timestamp.Builder builderForValue) {
      if (lastEventTimeBuilder_ == null) {
        lastEventTime_ = builderForValue.build();
      } else {
        lastEventTimeBuilder_.setMessage(builderForValue.build());
      }
      bitField0_ |= 0x00000020;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * [Output only] The last time a telemetry event was received. Timestamps are
     * periodically collected and written to storage; they may be stale by a few
     * minutes.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_event_time = 8;</code>
     */
    public Builder mergeLastEventTime(com.google.protobuf.Timestamp value) {
      if (lastEventTimeBuilder_ == null) {
        if (((bitField0_ & 0x00000020) != 0)
            && lastEventTime_ != null
            && lastEventTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) {
          getLastEventTimeBuilder().mergeFrom(value);
        } else {
          lastEventTime_ = value;
        }
      } else {
        lastEventTimeBuilder_.mergeFrom(value);
      }
      bitField0_ |= 0x00000020;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * [Output only] The last time a telemetry event was received. Timestamps are
     * periodically collected and written to storage; they may be stale by a few
     * minutes.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_event_time = 8;</code>
     */
    public Builder clearLastEventTime() {
      bitField0_ = (bitField0_ & ~0x00000020);
      lastEventTime_ = null;
      if (lastEventTimeBuilder_ != null) {
        lastEventTimeBuilder_.dispose();
        lastEventTimeBuilder_ = null;
      }
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * [Output only] The last time a telemetry event was received. Timestamps are
     * periodically collected and written to storage; they may be stale by a few
     * minutes.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_event_time = 8;</code>
     */
    public com.google.protobuf.Timestamp.Builder getLastEventTimeBuilder() {
      bitField0_ |= 0x00000020;
      onChanged();
      return getLastEventTimeFieldBuilder().getBuilder();
    }
    /**
     *
     *
     * <pre>
     * [Output only] The last time a telemetry event was received. Timestamps are
     * periodically collected and written to storage; they may be stale by a few
     * minutes.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_event_time = 8;</code>
     */
    public com.google.protobuf.TimestampOrBuilder getLastEventTimeOrBuilder() {
      if (lastEventTimeBuilder_ != null) {
        return lastEventTimeBuilder_.getMessageOrBuilder();
      } else {
        return lastEventTime_ == null
            ? com.google.protobuf.Timestamp.getDefaultInstance()
            : lastEventTime_;
      }
    }
    /**
     *
     *
     * <pre>
     * [Output only] The last time a telemetry event was received. Timestamps are
     * periodically collected and written to storage; they may be stale by a few
     * minutes.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_event_time = 8;</code>
     */
    private com.google.protobuf.SingleFieldBuilderV3<
            com.google.protobuf.Timestamp,
            com.google.protobuf.Timestamp.Builder,
            com.google.protobuf.TimestampOrBuilder>
        getLastEventTimeFieldBuilder() {
      if (lastEventTimeBuilder_ == null) {
        lastEventTimeBuilder_ =
            new com.google.protobuf.SingleFieldBuilderV3<
                com.google.protobuf.Timestamp,
                com.google.protobuf.Timestamp.Builder,
                com.google.protobuf.TimestampOrBuilder>(
                getLastEventTime(), getParentForChildren(), isClean());
        lastEventTime_ = null;
      }
      return lastEventTimeBuilder_;
    }

    private com.google.protobuf.Timestamp lastStateTime_;
    private com.google.protobuf.SingleFieldBuilderV3<
            com.google.protobuf.Timestamp,
            com.google.protobuf.Timestamp.Builder,
            com.google.protobuf.TimestampOrBuilder>
        lastStateTimeBuilder_;
    /**
     *
     *
     * <pre>
     * [Output only] The last time a state event was received. Timestamps are
     * periodically collected and written to storage; they may be stale by a few
     * minutes.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_state_time = 20;</code>
     *
     * @return Whether the lastStateTime field is set.
     */
    public boolean hasLastStateTime() {
      return ((bitField0_ & 0x00000040) != 0);
    }
    /**
     *
     *
     * <pre>
     * [Output only] The last time a state event was received. Timestamps are
     * periodically collected and written to storage; they may be stale by a few
     * minutes.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_state_time = 20;</code>
     *
     * @return The lastStateTime.
     */
    public com.google.protobuf.Timestamp getLastStateTime() {
      if (lastStateTimeBuilder_ == null) {
        return lastStateTime_ == null
            ? com.google.protobuf.Timestamp.getDefaultInstance()
            : lastStateTime_;
      } else {
        return lastStateTimeBuilder_.getMessage();
      }
    }
    /**
     *
     *
     * <pre>
     * [Output only] The last time a state event was received. Timestamps are
     * periodically collected and written to storage; they may be stale by a few
     * minutes.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_state_time = 20;</code>
     */
    public Builder setLastStateTime(com.google.protobuf.Timestamp value) {
      if (lastStateTimeBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        lastStateTime_ = value;
      } else {
        lastStateTimeBuilder_.setMessage(value);
      }
      bitField0_ |= 0x00000040;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * [Output only] The last time a state event was received. Timestamps are
     * periodically collected and written to storage; they may be stale by a few
     * minutes.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_state_time = 20;</code>
     */
    public Builder setLastStateTime(com.google.protobuf.Timestamp.Builder builderForValue) {
      if (lastStateTimeBuilder_ == null) {
        lastStateTime_ = builderForValue.build();
      } else {
        lastStateTimeBuilder_.setMessage(builderForValue.build());
      }
      bitField0_ |= 0x00000040;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * [Output only] The last time a state event was received. Timestamps are
     * periodically collected and written to storage; they may be stale by a few
     * minutes.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_state_time = 20;</code>
     */
    public Builder mergeLastStateTime(com.google.protobuf.Timestamp value) {
      if (lastStateTimeBuilder_ == null) {
        if (((bitField0_ & 0x00000040) != 0)
            && lastStateTime_ != null
            && lastStateTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) {
          getLastStateTimeBuilder().mergeFrom(value);
        } else {
          lastStateTime_ = value;
        }
      } else {
        lastStateTimeBuilder_.mergeFrom(value);
      }
      bitField0_ |= 0x00000040;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * [Output only] The last time a state event was received. Timestamps are
     * periodically collected and written to storage; they may be stale by a few
     * minutes.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_state_time = 20;</code>
     */
    public Builder clearLastStateTime() {
      bitField0_ = (bitField0_ & ~0x00000040);
      lastStateTime_ = null;
      if (lastStateTimeBuilder_ != null) {
        lastStateTimeBuilder_.dispose();
        lastStateTimeBuilder_ = null;
      }
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * [Output only] The last time a state event was received. Timestamps are
     * periodically collected and written to storage; they may be stale by a few
     * minutes.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_state_time = 20;</code>
     */
    public com.google.protobuf.Timestamp.Builder getLastStateTimeBuilder() {
      bitField0_ |= 0x00000040;
      onChanged();
      return getLastStateTimeFieldBuilder().getBuilder();
    }
    /**
     *
     *
     * <pre>
     * [Output only] The last time a state event was received. Timestamps are
     * periodically collected and written to storage; they may be stale by a few
     * minutes.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_state_time = 20;</code>
     */
    public com.google.protobuf.TimestampOrBuilder getLastStateTimeOrBuilder() {
      if (lastStateTimeBuilder_ != null) {
        return lastStateTimeBuilder_.getMessageOrBuilder();
      } else {
        return lastStateTime_ == null
            ? com.google.protobuf.Timestamp.getDefaultInstance()
            : lastStateTime_;
      }
    }
    /**
     *
     *
     * <pre>
     * [Output only] The last time a state event was received. Timestamps are
     * periodically collected and written to storage; they may be stale by a few
     * minutes.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_state_time = 20;</code>
     */
    private com.google.protobuf.SingleFieldBuilderV3<
            com.google.protobuf.Timestamp,
            com.google.protobuf.Timestamp.Builder,
            com.google.protobuf.TimestampOrBuilder>
        getLastStateTimeFieldBuilder() {
      if (lastStateTimeBuilder_ == null) {
        lastStateTimeBuilder_ =
            new com.google.protobuf.SingleFieldBuilderV3<
                com.google.protobuf.Timestamp,
                com.google.protobuf.Timestamp.Builder,
                com.google.protobuf.TimestampOrBuilder>(
                getLastStateTime(), getParentForChildren(), isClean());
        lastStateTime_ = null;
      }
      return lastStateTimeBuilder_;
    }

    private com.google.protobuf.Timestamp lastConfigAckTime_;
    private com.google.protobuf.SingleFieldBuilderV3<
            com.google.protobuf.Timestamp,
            com.google.protobuf.Timestamp.Builder,
            com.google.protobuf.TimestampOrBuilder>
        lastConfigAckTimeBuilder_;
    /**
     *
     *
     * <pre>
     * [Output only] The last time a cloud-to-device config version acknowledgment
     * was received from the device. This field is only for configurations
     * sent through MQTT.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_config_ack_time = 14;</code>
     *
     * @return Whether the lastConfigAckTime field is set.
     */
    public boolean hasLastConfigAckTime() {
      return ((bitField0_ & 0x00000080) != 0);
    }
    /**
     *
     *
     * <pre>
     * [Output only] The last time a cloud-to-device config version acknowledgment
     * was received from the device. This field is only for configurations
     * sent through MQTT.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_config_ack_time = 14;</code>
     *
     * @return The lastConfigAckTime.
     */
    public com.google.protobuf.Timestamp getLastConfigAckTime() {
      if (lastConfigAckTimeBuilder_ == null) {
        return lastConfigAckTime_ == null
            ? com.google.protobuf.Timestamp.getDefaultInstance()
            : lastConfigAckTime_;
      } else {
        return lastConfigAckTimeBuilder_.getMessage();
      }
    }
    /**
     *
     *
     * <pre>
     * [Output only] The last time a cloud-to-device config version acknowledgment
     * was received from the device. This field is only for configurations
     * sent through MQTT.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_config_ack_time = 14;</code>
     */
    public Builder setLastConfigAckTime(com.google.protobuf.Timestamp value) {
      if (lastConfigAckTimeBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        lastConfigAckTime_ = value;
      } else {
        lastConfigAckTimeBuilder_.setMessage(value);
      }
      bitField0_ |= 0x00000080;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * [Output only] The last time a cloud-to-device config version acknowledgment
     * was received from the device. This field is only for configurations
     * sent through MQTT.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_config_ack_time = 14;</code>
     */
    public Builder setLastConfigAckTime(com.google.protobuf.Timestamp.Builder builderForValue) {
      if (lastConfigAckTimeBuilder_ == null) {
        lastConfigAckTime_ = builderForValue.build();
      } else {
        lastConfigAckTimeBuilder_.setMessage(builderForValue.build());
      }
      bitField0_ |= 0x00000080;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * [Output only] The last time a cloud-to-device config version acknowledgment
     * was received from the device. This field is only for configurations
     * sent through MQTT.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_config_ack_time = 14;</code>
     */
    public Builder mergeLastConfigAckTime(com.google.protobuf.Timestamp value) {
      if (lastConfigAckTimeBuilder_ == null) {
        if (((bitField0_ & 0x00000080) != 0)
            && lastConfigAckTime_ != null
            && lastConfigAckTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) {
          getLastConfigAckTimeBuilder().mergeFrom(value);
        } else {
          lastConfigAckTime_ = value;
        }
      } else {
        lastConfigAckTimeBuilder_.mergeFrom(value);
      }
      bitField0_ |= 0x00000080;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * [Output only] The last time a cloud-to-device config version acknowledgment
     * was received from the device. This field is only for configurations
     * sent through MQTT.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_config_ack_time = 14;</code>
     */
    public Builder clearLastConfigAckTime() {
      bitField0_ = (bitField0_ & ~0x00000080);
      lastConfigAckTime_ = null;
      if (lastConfigAckTimeBuilder_ != null) {
        lastConfigAckTimeBuilder_.dispose();
        lastConfigAckTimeBuilder_ = null;
      }
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * [Output only] The last time a cloud-to-device config version acknowledgment
     * was received from the device. This field is only for configurations
     * sent through MQTT.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_config_ack_time = 14;</code>
     */
    public com.google.protobuf.Timestamp.Builder getLastConfigAckTimeBuilder() {
      bitField0_ |= 0x00000080;
      onChanged();
      return getLastConfigAckTimeFieldBuilder().getBuilder();
    }
    /**
     *
     *
     * <pre>
     * [Output only] The last time a cloud-to-device config version acknowledgment
     * was received from the device. This field is only for configurations
     * sent through MQTT.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_config_ack_time = 14;</code>
     */
    public com.google.protobuf.TimestampOrBuilder getLastConfigAckTimeOrBuilder() {
      if (lastConfigAckTimeBuilder_ != null) {
        return lastConfigAckTimeBuilder_.getMessageOrBuilder();
      } else {
        return lastConfigAckTime_ == null
            ? com.google.protobuf.Timestamp.getDefaultInstance()
            : lastConfigAckTime_;
      }
    }
    /**
     *
     *
     * <pre>
     * [Output only] The last time a cloud-to-device config version acknowledgment
     * was received from the device. This field is only for configurations
     * sent through MQTT.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_config_ack_time = 14;</code>
     */
    private com.google.protobuf.SingleFieldBuilderV3<
            com.google.protobuf.Timestamp,
            com.google.protobuf.Timestamp.Builder,
            com.google.protobuf.TimestampOrBuilder>
        getLastConfigAckTimeFieldBuilder() {
      if (lastConfigAckTimeBuilder_ == null) {
        lastConfigAckTimeBuilder_ =
            new com.google.protobuf.SingleFieldBuilderV3<
                com.google.protobuf.Timestamp,
                com.google.protobuf.Timestamp.Builder,
                com.google.protobuf.TimestampOrBuilder>(
                getLastConfigAckTime(), getParentForChildren(), isClean());
        lastConfigAckTime_ = null;
      }
      return lastConfigAckTimeBuilder_;
    }

    private com.google.protobuf.Timestamp lastConfigSendTime_;
    private com.google.protobuf.SingleFieldBuilderV3<
            com.google.protobuf.Timestamp,
            com.google.protobuf.Timestamp.Builder,
            com.google.protobuf.TimestampOrBuilder>
        lastConfigSendTimeBuilder_;
    /**
     *
     *
     * <pre>
     * [Output only] The last time a cloud-to-device config version was sent to
     * the device.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_config_send_time = 18;</code>
     *
     * @return Whether the lastConfigSendTime field is set.
     */
    public boolean hasLastConfigSendTime() {
      return ((bitField0_ & 0x00000100) != 0);
    }
    /**
     *
     *
     * <pre>
     * [Output only] The last time a cloud-to-device config version was sent to
     * the device.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_config_send_time = 18;</code>
     *
     * @return The lastConfigSendTime.
     */
    public com.google.protobuf.Timestamp getLastConfigSendTime() {
      if (lastConfigSendTimeBuilder_ == null) {
        return lastConfigSendTime_ == null
            ? com.google.protobuf.Timestamp.getDefaultInstance()
            : lastConfigSendTime_;
      } else {
        return lastConfigSendTimeBuilder_.getMessage();
      }
    }
    /**
     *
     *
     * <pre>
     * [Output only] The last time a cloud-to-device config version was sent to
     * the device.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_config_send_time = 18;</code>
     */
    public Builder setLastConfigSendTime(com.google.protobuf.Timestamp value) {
      if (lastConfigSendTimeBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        lastConfigSendTime_ = value;
      } else {
        lastConfigSendTimeBuilder_.setMessage(value);
      }
      bitField0_ |= 0x00000100;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * [Output only] The last time a cloud-to-device config version was sent to
     * the device.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_config_send_time = 18;</code>
     */
    public Builder setLastConfigSendTime(com.google.protobuf.Timestamp.Builder builderForValue) {
      if (lastConfigSendTimeBuilder_ == null) {
        lastConfigSendTime_ = builderForValue.build();
      } else {
        lastConfigSendTimeBuilder_.setMessage(builderForValue.build());
      }
      bitField0_ |= 0x00000100;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * [Output only] The last time a cloud-to-device config version was sent to
     * the device.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_config_send_time = 18;</code>
     */
    public Builder mergeLastConfigSendTime(com.google.protobuf.Timestamp value) {
      if (lastConfigSendTimeBuilder_ == null) {
        if (((bitField0_ & 0x00000100) != 0)
            && lastConfigSendTime_ != null
            && lastConfigSendTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) {
          getLastConfigSendTimeBuilder().mergeFrom(value);
        } else {
          lastConfigSendTime_ = value;
        }
      } else {
        lastConfigSendTimeBuilder_.mergeFrom(value);
      }
      bitField0_ |= 0x00000100;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * [Output only] The last time a cloud-to-device config version was sent to
     * the device.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_config_send_time = 18;</code>
     */
    public Builder clearLastConfigSendTime() {
      bitField0_ = (bitField0_ & ~0x00000100);
      lastConfigSendTime_ = null;
      if (lastConfigSendTimeBuilder_ != null) {
        lastConfigSendTimeBuilder_.dispose();
        lastConfigSendTimeBuilder_ = null;
      }
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * [Output only] The last time a cloud-to-device config version was sent to
     * the device.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_config_send_time = 18;</code>
     */
    public com.google.protobuf.Timestamp.Builder getLastConfigSendTimeBuilder() {
      bitField0_ |= 0x00000100;
      onChanged();
      return getLastConfigSendTimeFieldBuilder().getBuilder();
    }
    /**
     *
     *
     * <pre>
     * [Output only] The last time a cloud-to-device config version was sent to
     * the device.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_config_send_time = 18;</code>
     */
    public com.google.protobuf.TimestampOrBuilder getLastConfigSendTimeOrBuilder() {
      if (lastConfigSendTimeBuilder_ != null) {
        return lastConfigSendTimeBuilder_.getMessageOrBuilder();
      } else {
        return lastConfigSendTime_ == null
            ? com.google.protobuf.Timestamp.getDefaultInstance()
            : lastConfigSendTime_;
      }
    }
    /**
     *
     *
     * <pre>
     * [Output only] The last time a cloud-to-device config version was sent to
     * the device.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_config_send_time = 18;</code>
     */
    private com.google.protobuf.SingleFieldBuilderV3<
            com.google.protobuf.Timestamp,
            com.google.protobuf.Timestamp.Builder,
            com.google.protobuf.TimestampOrBuilder>
        getLastConfigSendTimeFieldBuilder() {
      if (lastConfigSendTimeBuilder_ == null) {
        lastConfigSendTimeBuilder_ =
            new com.google.protobuf.SingleFieldBuilderV3<
                com.google.protobuf.Timestamp,
                com.google.protobuf.Timestamp.Builder,
                com.google.protobuf.TimestampOrBuilder>(
                getLastConfigSendTime(), getParentForChildren(), isClean());
        lastConfigSendTime_ = null;
      }
      return lastConfigSendTimeBuilder_;
    }

    private boolean blocked_;
    /**
     *
     *
     * <pre>
     * If a device is blocked, connections or requests from this device will fail.
     * Can be used to temporarily prevent the device from connecting if, for
     * example, the sensor is generating bad data and needs maintenance.
     * </pre>
     *
     * <code>bool blocked = 19;</code>
     *
     * @return The blocked.
     */
    @java.lang.Override
    public boolean getBlocked() {
      return blocked_;
    }
    /**
     *
     *
     * <pre>
     * If a device is blocked, connections or requests from this device will fail.
     * Can be used to temporarily prevent the device from connecting if, for
     * example, the sensor is generating bad data and needs maintenance.
     * </pre>
     *
     * <code>bool blocked = 19;</code>
     *
     * @param value The blocked to set.
     * @return This builder for chaining.
     */
    public Builder setBlocked(boolean value) {

      blocked_ = value;
      bitField0_ |= 0x00000200;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * If a device is blocked, connections or requests from this device will fail.
     * Can be used to temporarily prevent the device from connecting if, for
     * example, the sensor is generating bad data and needs maintenance.
     * </pre>
     *
     * <code>bool blocked = 19;</code>
     *
     * @return This builder for chaining.
     */
    public Builder clearBlocked() {
      bitField0_ = (bitField0_ & ~0x00000200);
      blocked_ = false;
      onChanged();
      return this;
    }

    private com.google.protobuf.Timestamp lastErrorTime_;
    private com.google.protobuf.SingleFieldBuilderV3<
            com.google.protobuf.Timestamp,
            com.google.protobuf.Timestamp.Builder,
            com.google.protobuf.TimestampOrBuilder>
        lastErrorTimeBuilder_;
    /**
     *
     *
     * <pre>
     * [Output only] The time the most recent error occurred, such as a failure to
     * publish to Cloud Pub/Sub. This field is the timestamp of
     * 'last_error_status'.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_error_time = 10;</code>
     *
     * @return Whether the lastErrorTime field is set.
     */
    public boolean hasLastErrorTime() {
      return ((bitField0_ & 0x00000400) != 0);
    }
    /**
     *
     *
     * <pre>
     * [Output only] The time the most recent error occurred, such as a failure to
     * publish to Cloud Pub/Sub. This field is the timestamp of
     * 'last_error_status'.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_error_time = 10;</code>
     *
     * @return The lastErrorTime.
     */
    public com.google.protobuf.Timestamp getLastErrorTime() {
      if (lastErrorTimeBuilder_ == null) {
        return lastErrorTime_ == null
            ? com.google.protobuf.Timestamp.getDefaultInstance()
            : lastErrorTime_;
      } else {
        return lastErrorTimeBuilder_.getMessage();
      }
    }
    /**
     *
     *
     * <pre>
     * [Output only] The time the most recent error occurred, such as a failure to
     * publish to Cloud Pub/Sub. This field is the timestamp of
     * 'last_error_status'.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_error_time = 10;</code>
     */
    public Builder setLastErrorTime(com.google.protobuf.Timestamp value) {
      if (lastErrorTimeBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        lastErrorTime_ = value;
      } else {
        lastErrorTimeBuilder_.setMessage(value);
      }
      bitField0_ |= 0x00000400;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * [Output only] The time the most recent error occurred, such as a failure to
     * publish to Cloud Pub/Sub. This field is the timestamp of
     * 'last_error_status'.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_error_time = 10;</code>
     */
    public Builder setLastErrorTime(com.google.protobuf.Timestamp.Builder builderForValue) {
      if (lastErrorTimeBuilder_ == null) {
        lastErrorTime_ = builderForValue.build();
      } else {
        lastErrorTimeBuilder_.setMessage(builderForValue.build());
      }
      bitField0_ |= 0x00000400;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * [Output only] The time the most recent error occurred, such as a failure to
     * publish to Cloud Pub/Sub. This field is the timestamp of
     * 'last_error_status'.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_error_time = 10;</code>
     */
    public Builder mergeLastErrorTime(com.google.protobuf.Timestamp value) {
      if (lastErrorTimeBuilder_ == null) {
        if (((bitField0_ & 0x00000400) != 0)
            && lastErrorTime_ != null
            && lastErrorTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) {
          getLastErrorTimeBuilder().mergeFrom(value);
        } else {
          lastErrorTime_ = value;
        }
      } else {
        lastErrorTimeBuilder_.mergeFrom(value);
      }
      bitField0_ |= 0x00000400;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * [Output only] The time the most recent error occurred, such as a failure to
     * publish to Cloud Pub/Sub. This field is the timestamp of
     * 'last_error_status'.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_error_time = 10;</code>
     */
    public Builder clearLastErrorTime() {
      bitField0_ = (bitField0_ & ~0x00000400);
      lastErrorTime_ = null;
      if (lastErrorTimeBuilder_ != null) {
        lastErrorTimeBuilder_.dispose();
        lastErrorTimeBuilder_ = null;
      }
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * [Output only] The time the most recent error occurred, such as a failure to
     * publish to Cloud Pub/Sub. This field is the timestamp of
     * 'last_error_status'.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_error_time = 10;</code>
     */
    public com.google.protobuf.Timestamp.Builder getLastErrorTimeBuilder() {
      bitField0_ |= 0x00000400;
      onChanged();
      return getLastErrorTimeFieldBuilder().getBuilder();
    }
    /**
     *
     *
     * <pre>
     * [Output only] The time the most recent error occurred, such as a failure to
     * publish to Cloud Pub/Sub. This field is the timestamp of
     * 'last_error_status'.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_error_time = 10;</code>
     */
    public com.google.protobuf.TimestampOrBuilder getLastErrorTimeOrBuilder() {
      if (lastErrorTimeBuilder_ != null) {
        return lastErrorTimeBuilder_.getMessageOrBuilder();
      } else {
        return lastErrorTime_ == null
            ? com.google.protobuf.Timestamp.getDefaultInstance()
            : lastErrorTime_;
      }
    }
    /**
     *
     *
     * <pre>
     * [Output only] The time the most recent error occurred, such as a failure to
     * publish to Cloud Pub/Sub. This field is the timestamp of
     * 'last_error_status'.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp last_error_time = 10;</code>
     */
    private com.google.protobuf.SingleFieldBuilderV3<
            com.google.protobuf.Timestamp,
            com.google.protobuf.Timestamp.Builder,
            com.google.protobuf.TimestampOrBuilder>
        getLastErrorTimeFieldBuilder() {
      if (lastErrorTimeBuilder_ == null) {
        lastErrorTimeBuilder_ =
            new com.google.protobuf.SingleFieldBuilderV3<
                com.google.protobuf.Timestamp,
                com.google.protobuf.Timestamp.Builder,
                com.google.protobuf.TimestampOrBuilder>(
                getLastErrorTime(), getParentForChildren(), isClean());
        lastErrorTime_ = null;
      }
      return lastErrorTimeBuilder_;
    }

    private com.google.rpc.Status lastErrorStatus_;
    private com.google.protobuf.SingleFieldBuilderV3<
            com.google.rpc.Status, com.google.rpc.Status.Builder, com.google.rpc.StatusOrBuilder>
        lastErrorStatusBuilder_;
    /**
     *
     *
     * <pre>
     * [Output only] The error message of the most recent error, such as a failure
     * to publish to Cloud Pub/Sub. 'last_error_time' is the timestamp of this
     * field. If no errors have occurred, this field has an empty message
     * and the status code 0 == OK. Otherwise, this field is expected to have a
     * status code other than OK.
     * </pre>
     *
     * <code>.google.rpc.Status last_error_status = 11;</code>
     *
     * @return Whether the lastErrorStatus field is set.
     */
    public boolean hasLastErrorStatus() {
      return ((bitField0_ & 0x00000800) != 0);
    }
    /**
     *
     *
     * <pre>
     * [Output only] The error message of the most recent error, such as a failure
     * to publish to Cloud Pub/Sub. 'last_error_time' is the timestamp of this
     * field. If no errors have occurred, this field has an empty message
     * and the status code 0 == OK. Otherwise, this field is expected to have a
     * status code other than OK.
     * </pre>
     *
     * <code>.google.rpc.Status last_error_status = 11;</code>
     *
     * @return The lastErrorStatus.
     */
    public com.google.rpc.Status getLastErrorStatus() {
      if (lastErrorStatusBuilder_ == null) {
        return lastErrorStatus_ == null
            ? com.google.rpc.Status.getDefaultInstance()
            : lastErrorStatus_;
      } else {
        return lastErrorStatusBuilder_.getMessage();
      }
    }
    /**
     *
     *
     * <pre>
     * [Output only] The error message of the most recent error, such as a failure
     * to publish to Cloud Pub/Sub. 'last_error_time' is the timestamp of this
     * field. If no errors have occurred, this field has an empty message
     * and the status code 0 == OK. Otherwise, this field is expected to have a
     * status code other than OK.
     * </pre>
     *
     * <code>.google.rpc.Status last_error_status = 11;</code>
     */
    public Builder setLastErrorStatus(com.google.rpc.Status value) {
      if (lastErrorStatusBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        lastErrorStatus_ = value;
      } else {
        lastErrorStatusBuilder_.setMessage(value);
      }
      bitField0_ |= 0x00000800;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * [Output only] The error message of the most recent error, such as a failure
     * to publish to Cloud Pub/Sub. 'last_error_time' is the timestamp of this
     * field. If no errors have occurred, this field has an empty message
     * and the status code 0 == OK. Otherwise, this field is expected to have a
     * status code other than OK.
     * </pre>
     *
     * <code>.google.rpc.Status last_error_status = 11;</code>
     */
    public Builder setLastErrorStatus(com.google.rpc.Status.Builder builderForValue) {
      if (lastErrorStatusBuilder_ == null) {
        lastErrorStatus_ = builderForValue.build();
      } else {
        lastErrorStatusBuilder_.setMessage(builderForValue.build());
      }
      bitField0_ |= 0x00000800;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * [Output only] The error message of the most recent error, such as a failure
     * to publish to Cloud Pub/Sub. 'last_error_time' is the timestamp of this
     * field. If no errors have occurred, this field has an empty message
     * and the status code 0 == OK. Otherwise, this field is expected to have a
     * status code other than OK.
     * </pre>
     *
     * <code>.google.rpc.Status last_error_status = 11;</code>
     */
    public Builder mergeLastErrorStatus(com.google.rpc.Status value) {
      if (lastErrorStatusBuilder_ == null) {
        if (((bitField0_ & 0x00000800) != 0)
            && lastErrorStatus_ != null
            && lastErrorStatus_ != com.google.rpc.Status.getDefaultInstance()) {
          getLastErrorStatusBuilder().mergeFrom(value);
        } else {
          lastErrorStatus_ = value;
        }
      } else {
        lastErrorStatusBuilder_.mergeFrom(value);
      }
      bitField0_ |= 0x00000800;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * [Output only] The error message of the most recent error, such as a failure
     * to publish to Cloud Pub/Sub. 'last_error_time' is the timestamp of this
     * field. If no errors have occurred, this field has an empty message
     * and the status code 0 == OK. Otherwise, this field is expected to have a
     * status code other than OK.
     * </pre>
     *
     * <code>.google.rpc.Status last_error_status = 11;</code>
     */
    public Builder clearLastErrorStatus() {
      bitField0_ = (bitField0_ & ~0x00000800);
      lastErrorStatus_ = null;
      if (lastErrorStatusBuilder_ != null) {
        lastErrorStatusBuilder_.dispose();
        lastErrorStatusBuilder_ = null;
      }
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * [Output only] The error message of the most recent error, such as a failure
     * to publish to Cloud Pub/Sub. 'last_error_time' is the timestamp of this
     * field. If no errors have occurred, this field has an empty message
     * and the status code 0 == OK. Otherwise, this field is expected to have a
     * status code other than OK.
     * </pre>
     *
     * <code>.google.rpc.Status last_error_status = 11;</code>
     */
    public com.google.rpc.Status.Builder getLastErrorStatusBuilder() {
      bitField0_ |= 0x00000800;
      onChanged();
      return getLastErrorStatusFieldBuilder().getBuilder();
    }
    /**
     *
     *
     * <pre>
     * [Output only] The error message of the most recent error, such as a failure
     * to publish to Cloud Pub/Sub. 'last_error_time' is the timestamp of this
     * field. If no errors have occurred, this field has an empty message
     * and the status code 0 == OK. Otherwise, this field is expected to have a
     * status code other than OK.
     * </pre>
     *
     * <code>.google.rpc.Status last_error_status = 11;</code>
     */
    public com.google.rpc.StatusOrBuilder getLastErrorStatusOrBuilder() {
      if (lastErrorStatusBuilder_ != null) {
        return lastErrorStatusBuilder_.getMessageOrBuilder();
      } else {
        return lastErrorStatus_ == null
            ? com.google.rpc.Status.getDefaultInstance()
            : lastErrorStatus_;
      }
    }
    /**
     *
     *
     * <pre>
     * [Output only] The error message of the most recent error, such as a failure
     * to publish to Cloud Pub/Sub. 'last_error_time' is the timestamp of this
     * field. If no errors have occurred, this field has an empty message
     * and the status code 0 == OK. Otherwise, this field is expected to have a
     * status code other than OK.
     * </pre>
     *
     * <code>.google.rpc.Status last_error_status = 11;</code>
     */
    private com.google.protobuf.SingleFieldBuilderV3<
            com.google.rpc.Status, com.google.rpc.Status.Builder, com.google.rpc.StatusOrBuilder>
        getLastErrorStatusFieldBuilder() {
      if (lastErrorStatusBuilder_ == null) {
        lastErrorStatusBuilder_ =
            new com.google.protobuf.SingleFieldBuilderV3<
                com.google.rpc.Status,
                com.google.rpc.Status.Builder,
                com.google.rpc.StatusOrBuilder>(
                getLastErrorStatus(), getParentForChildren(), isClean());
        lastErrorStatus_ = null;
      }
      return lastErrorStatusBuilder_;
    }

    private com.google.cloud.iot.v1.DeviceConfig config_;
    private com.google.protobuf.SingleFieldBuilderV3<
            com.google.cloud.iot.v1.DeviceConfig,
            com.google.cloud.iot.v1.DeviceConfig.Builder,
            com.google.cloud.iot.v1.DeviceConfigOrBuilder>
        configBuilder_;
    /**
     *
     *
     * <pre>
     * The most recent device configuration, which is eventually sent from
     * Cloud IoT Core to the device. If not present on creation, the
     * configuration will be initialized with an empty payload and version value
     * of `1`. To update this field after creation, use the
     * `DeviceManager.ModifyCloudToDeviceConfig` method.
     * </pre>
     *
     * <code>.google.cloud.iot.v1.DeviceConfig config = 13;</code>
     *
     * @return Whether the config field is set.
     */
    public boolean hasConfig() {
      return ((bitField0_ & 0x00001000) != 0);
    }
    /**
     *
     *
     * <pre>
     * The most recent device configuration, which is eventually sent from
     * Cloud IoT Core to the device. If not present on creation, the
     * configuration will be initialized with an empty payload and version value
     * of `1`. To update this field after creation, use the
     * `DeviceManager.ModifyCloudToDeviceConfig` method.
     * </pre>
     *
     * <code>.google.cloud.iot.v1.DeviceConfig config = 13;</code>
     *
     * @return The config.
     */
    public com.google.cloud.iot.v1.DeviceConfig getConfig() {
      if (configBuilder_ == null) {
        return config_ == null
            ? com.google.cloud.iot.v1.DeviceConfig.getDefaultInstance()
            : config_;
      } else {
        return configBuilder_.getMessage();
      }
    }
    /**
     *
     *
     * <pre>
     * The most recent device configuration, which is eventually sent from
     * Cloud IoT Core to the device. If not present on creation, the
     * configuration will be initialized with an empty payload and version value
     * of `1`. To update this field after creation, use the
     * `DeviceManager.ModifyCloudToDeviceConfig` method.
     * </pre>
     *
     * <code>.google.cloud.iot.v1.DeviceConfig config = 13;</code>
     */
    public Builder setConfig(com.google.cloud.iot.v1.DeviceConfig value) {
      if (configBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        config_ = value;
      } else {
        configBuilder_.setMessage(value);
      }
      bitField0_ |= 0x00001000;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * The most recent device configuration, which is eventually sent from
     * Cloud IoT Core to the device. If not present on creation, the
     * configuration will be initialized with an empty payload and version value
     * of `1`. To update this field after creation, use the
     * `DeviceManager.ModifyCloudToDeviceConfig` method.
     * </pre>
     *
     * <code>.google.cloud.iot.v1.DeviceConfig config = 13;</code>
     */
    public Builder setConfig(com.google.cloud.iot.v1.DeviceConfig.Builder builderForValue) {
      if (configBuilder_ == null) {
        config_ = builderForValue.build();
      } else {
        configBuilder_.setMessage(builderForValue.build());
      }
      bitField0_ |= 0x00001000;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * The most recent device configuration, which is eventually sent from
     * Cloud IoT Core to the device. If not present on creation, the
     * configuration will be initialized with an empty payload and version value
     * of `1`. To update this field after creation, use the
     * `DeviceManager.ModifyCloudToDeviceConfig` method.
     * </pre>
     *
     * <code>.google.cloud.iot.v1.DeviceConfig config = 13;</code>
     */
    public Builder mergeConfig(com.google.cloud.iot.v1.DeviceConfig value) {
      if (configBuilder_ == null) {
        if (((bitField0_ & 0x00001000) != 0)
            && config_ != null
            && config_ != com.google.cloud.iot.v1.DeviceConfig.getDefaultInstance()) {
          getConfigBuilder().mergeFrom(value);
        } else {
          config_ = value;
        }
      } else {
        configBuilder_.mergeFrom(value);
      }
      bitField0_ |= 0x00001000;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * The most recent device configuration, which is eventually sent from
     * Cloud IoT Core to the device. If not present on creation, the
     * configuration will be initialized with an empty payload and version value
     * of `1`. To update this field after creation, use the
     * `DeviceManager.ModifyCloudToDeviceConfig` method.
     * </pre>
     *
     * <code>.google.cloud.iot.v1.DeviceConfig config = 13;</code>
     */
    public Builder clearConfig() {
      bitField0_ = (bitField0_ & ~0x00001000);
      config_ = null;
      if (configBuilder_ != null) {
        configBuilder_.dispose();
        configBuilder_ = null;
      }
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * The most recent device configuration, which is eventually sent from
     * Cloud IoT Core to the device. If not present on creation, the
     * configuration will be initialized with an empty payload and version value
     * of `1`. To update this field after creation, use the
     * `DeviceManager.ModifyCloudToDeviceConfig` method.
     * </pre>
     *
     * <code>.google.cloud.iot.v1.DeviceConfig config = 13;</code>
     */
    public com.google.cloud.iot.v1.DeviceConfig.Builder getConfigBuilder() {
      bitField0_ |= 0x00001000;
      onChanged();
      return getConfigFieldBuilder().getBuilder();
    }
    /**
     *
     *
     * <pre>
     * The most recent device configuration, which is eventually sent from
     * Cloud IoT Core to the device. If not present on creation, the
     * configuration will be initialized with an empty payload and version value
     * of `1`. To update this field after creation, use the
     * `DeviceManager.ModifyCloudToDeviceConfig` method.
     * </pre>
     *
     * <code>.google.cloud.iot.v1.DeviceConfig config = 13;</code>
     */
    public com.google.cloud.iot.v1.DeviceConfigOrBuilder getConfigOrBuilder() {
      if (configBuilder_ != null) {
        return configBuilder_.getMessageOrBuilder();
      } else {
        return config_ == null
            ? com.google.cloud.iot.v1.DeviceConfig.getDefaultInstance()
            : config_;
      }
    }
    /**
     *
     *
     * <pre>
     * The most recent device configuration, which is eventually sent from
     * Cloud IoT Core to the device. If not present on creation, the
     * configuration will be initialized with an empty payload and version value
     * of `1`. To update this field after creation, use the
     * `DeviceManager.ModifyCloudToDeviceConfig` method.
     * </pre>
     *
     * <code>.google.cloud.iot.v1.DeviceConfig config = 13;</code>
     */
    private com.google.protobuf.SingleFieldBuilderV3<
            com.google.cloud.iot.v1.DeviceConfig,
            com.google.cloud.iot.v1.DeviceConfig.Builder,
            com.google.cloud.iot.v1.DeviceConfigOrBuilder>
        getConfigFieldBuilder() {
      if (configBuilder_ == null) {
        configBuilder_ =
            new com.google.protobuf.SingleFieldBuilderV3<
                com.google.cloud.iot.v1.DeviceConfig,
                com.google.cloud.iot.v1.DeviceConfig.Builder,
                com.google.cloud.iot.v1.DeviceConfigOrBuilder>(
                getConfig(), getParentForChildren(), isClean());
        config_ = null;
      }
      return configBuilder_;
    }

    private com.google.cloud.iot.v1.DeviceState state_;
    private com.google.protobuf.SingleFieldBuilderV3<
            com.google.cloud.iot.v1.DeviceState,
            com.google.cloud.iot.v1.DeviceState.Builder,
            com.google.cloud.iot.v1.DeviceStateOrBuilder>
        stateBuilder_;
    /**
     *
     *
     * <pre>
     * [Output only] The state most recently received from the device. If no state
     * has been reported, this field is not present.
     * </pre>
     *
     * <code>.google.cloud.iot.v1.DeviceState state = 16;</code>
     *
     * @return Whether the state field is set.
     */
    public boolean hasState() {
      return ((bitField0_ & 0x00002000) != 0);
    }
    /**
     *
     *
     * <pre>
     * [Output only] The state most recently received from the device. If no state
     * has been reported, this field is not present.
     * </pre>
     *
     * <code>.google.cloud.iot.v1.DeviceState state = 16;</code>
     *
     * @return The state.
     */
    public com.google.cloud.iot.v1.DeviceState getState() {
      if (stateBuilder_ == null) {
        return state_ == null ? com.google.cloud.iot.v1.DeviceState.getDefaultInstance() : state_;
      } else {
        return stateBuilder_.getMessage();
      }
    }
    /**
     *
     *
     * <pre>
     * [Output only] The state most recently received from the device. If no state
     * has been reported, this field is not present.
     * </pre>
     *
     * <code>.google.cloud.iot.v1.DeviceState state = 16;</code>
     */
    public Builder setState(com.google.cloud.iot.v1.DeviceState value) {
      if (stateBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        state_ = value;
      } else {
        stateBuilder_.setMessage(value);
      }
      bitField0_ |= 0x00002000;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * [Output only] The state most recently received from the device. If no state
     * has been reported, this field is not present.
     * </pre>
     *
     * <code>.google.cloud.iot.v1.DeviceState state = 16;</code>
     */
    public Builder setState(com.google.cloud.iot.v1.DeviceState.Builder builderForValue) {
      if (stateBuilder_ == null) {
        state_ = builderForValue.build();
      } else {
        stateBuilder_.setMessage(builderForValue.build());
      }
      bitField0_ |= 0x00002000;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * [Output only] The state most recently received from the device. If no state
     * has been reported, this field is not present.
     * </pre>
     *
     * <code>.google.cloud.iot.v1.DeviceState state = 16;</code>
     */
    public Builder mergeState(com.google.cloud.iot.v1.DeviceState value) {
      if (stateBuilder_ == null) {
        if (((bitField0_ & 0x00002000) != 0)
            && state_ != null
            && state_ != com.google.cloud.iot.v1.DeviceState.getDefaultInstance()) {
          getStateBuilder().mergeFrom(value);
        } else {
          state_ = value;
        }
      } else {
        stateBuilder_.mergeFrom(value);
      }
      bitField0_ |= 0x00002000;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * [Output only] The state most recently received from the device. If no state
     * has been reported, this field is not present.
     * </pre>
     *
     * <code>.google.cloud.iot.v1.DeviceState state = 16;</code>
     */
    public Builder clearState() {
      bitField0_ = (bitField0_ & ~0x00002000);
      state_ = null;
      if (stateBuilder_ != null) {
        stateBuilder_.dispose();
        stateBuilder_ = null;
      }
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * [Output only] The state most recently received from the device. If no state
     * has been reported, this field is not present.
     * </pre>
     *
     * <code>.google.cloud.iot.v1.DeviceState state = 16;</code>
     */
    public com.google.cloud.iot.v1.DeviceState.Builder getStateBuilder() {
      bitField0_ |= 0x00002000;
      onChanged();
      return getStateFieldBuilder().getBuilder();
    }
    /**
     *
     *
     * <pre>
     * [Output only] The state most recently received from the device. If no state
     * has been reported, this field is not present.
     * </pre>
     *
     * <code>.google.cloud.iot.v1.DeviceState state = 16;</code>
     */
    public com.google.cloud.iot.v1.DeviceStateOrBuilder getStateOrBuilder() {
      if (stateBuilder_ != null) {
        return stateBuilder_.getMessageOrBuilder();
      } else {
        return state_ == null ? com.google.cloud.iot.v1.DeviceState.getDefaultInstance() : state_;
      }
    }
    /**
     *
     *
     * <pre>
     * [Output only] The state most recently received from the device. If no state
     * has been reported, this field is not present.
     * </pre>
     *
     * <code>.google.cloud.iot.v1.DeviceState state = 16;</code>
     */
    private com.google.protobuf.SingleFieldBuilderV3<
            com.google.cloud.iot.v1.DeviceState,
            com.google.cloud.iot.v1.DeviceState.Builder,
            com.google.cloud.iot.v1.DeviceStateOrBuilder>
        getStateFieldBuilder() {
      if (stateBuilder_ == null) {
        stateBuilder_ =
            new com.google.protobuf.SingleFieldBuilderV3<
                com.google.cloud.iot.v1.DeviceState,
                com.google.cloud.iot.v1.DeviceState.Builder,
                com.google.cloud.iot.v1.DeviceStateOrBuilder>(
                getState(), getParentForChildren(), isClean());
        state_ = null;
      }
      return stateBuilder_;
    }

    private int logLevel_ = 0;
    /**
     *
     *
     * <pre>
     * **Beta Feature**
     *
     * The logging verbosity for device activity. If unspecified,
     * DeviceRegistry.log_level will be used.
     * </pre>
     *
     * <code>.google.cloud.iot.v1.LogLevel log_level = 21;</code>
     *
     * @return The enum numeric value on the wire for logLevel.
     */
    @java.lang.Override
    public int getLogLevelValue() {
      return logLevel_;
    }
    /**
     *
     *
     * <pre>
     * **Beta Feature**
     *
     * The logging verbosity for device activity. If unspecified,
     * DeviceRegistry.log_level will be used.
     * </pre>
     *
     * <code>.google.cloud.iot.v1.LogLevel log_level = 21;</code>
     *
     * @param value The enum numeric value on the wire for logLevel to set.
     * @return This builder for chaining.
     */
    public Builder setLogLevelValue(int value) {
      logLevel_ = value;
      bitField0_ |= 0x00004000;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * **Beta Feature**
     *
     * The logging verbosity for device activity. If unspecified,
     * DeviceRegistry.log_level will be used.
     * </pre>
     *
     * <code>.google.cloud.iot.v1.LogLevel log_level = 21;</code>
     *
     * @return The logLevel.
     */
    @java.lang.Override
    public com.google.cloud.iot.v1.LogLevel getLogLevel() {
      com.google.cloud.iot.v1.LogLevel result =
          com.google.cloud.iot.v1.LogLevel.forNumber(logLevel_);
      return result == null ? com.google.cloud.iot.v1.LogLevel.UNRECOGNIZED : result;
    }
    /**
     *
     *
     * <pre>
     * **Beta Feature**
     *
     * The logging verbosity for device activity. If unspecified,
     * DeviceRegistry.log_level will be used.
     * </pre>
     *
     * <code>.google.cloud.iot.v1.LogLevel log_level = 21;</code>
     *
     * @param value The logLevel to set.
     * @return This builder for chaining.
     */
    public Builder setLogLevel(com.google.cloud.iot.v1.LogLevel value) {
      if (value == null) {
        throw new NullPointerException();
      }
      bitField0_ |= 0x00004000;
      logLevel_ = value.getNumber();
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * **Beta Feature**
     *
     * The logging verbosity for device activity. If unspecified,
     * DeviceRegistry.log_level will be used.
     * </pre>
     *
     * <code>.google.cloud.iot.v1.LogLevel log_level = 21;</code>
     *
     * @return This builder for chaining.
     */
    public Builder clearLogLevel() {
      bitField0_ = (bitField0_ & ~0x00004000);
      logLevel_ = 0;
      onChanged();
      return this;
    }

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

    private com.google.protobuf.MapField<java.lang.String, java.lang.String> internalGetMetadata() {
      if (metadata_ == null) {
        return com.google.protobuf.MapField.emptyMapField(MetadataDefaultEntryHolder.defaultEntry);
      }
      return metadata_;
    }

    private com.google.protobuf.MapField<java.lang.String, java.lang.String>
        internalGetMutableMetadata() {
      if (metadata_ == null) {
        metadata_ =
            com.google.protobuf.MapField.newMapField(MetadataDefaultEntryHolder.defaultEntry);
      }
      if (!metadata_.isMutable()) {
        metadata_ = metadata_.copy();
      }
      bitField0_ |= 0x00008000;
      onChanged();
      return metadata_;
    }

    public int getMetadataCount() {
      return internalGetMetadata().getMap().size();
    }
    /**
     *
     *
     * <pre>
     * The metadata key-value pairs assigned to the device. This metadata is not
     * interpreted or indexed by Cloud IoT Core. It can be used to add contextual
     * information for the device.
     *
     * Keys must conform to the regular expression [a-zA-Z][a-zA-Z0-9-_.+~%]+ and
     * be less than 128 bytes in length.
     *
     * Values are free-form strings. Each value must be less than or equal to 32
     * KB in size.
     *
     * The total size of all keys and values must be less than 256 KB, and the
     * maximum number of key-value pairs is 500.
     * </pre>
     *
     * <code>map&lt;string, string&gt; metadata = 17;</code>
     */
    @java.lang.Override
    public boolean containsMetadata(java.lang.String key) {
      if (key == null) {
        throw new NullPointerException("map key");
      }
      return internalGetMetadata().getMap().containsKey(key);
    }
    /** Use {@link #getMetadataMap()} instead. */
    @java.lang.Override
    @java.lang.Deprecated
    public java.util.Map<java.lang.String, java.lang.String> getMetadata() {
      return getMetadataMap();
    }
    /**
     *
     *
     * <pre>
     * The metadata key-value pairs assigned to the device. This metadata is not
     * interpreted or indexed by Cloud IoT Core. It can be used to add contextual
     * information for the device.
     *
     * Keys must conform to the regular expression [a-zA-Z][a-zA-Z0-9-_.+~%]+ and
     * be less than 128 bytes in length.
     *
     * Values are free-form strings. Each value must be less than or equal to 32
     * KB in size.
     *
     * The total size of all keys and values must be less than 256 KB, and the
     * maximum number of key-value pairs is 500.
     * </pre>
     *
     * <code>map&lt;string, string&gt; metadata = 17;</code>
     */
    @java.lang.Override
    public java.util.Map<java.lang.String, java.lang.String> getMetadataMap() {
      return internalGetMetadata().getMap();
    }
    /**
     *
     *
     * <pre>
     * The metadata key-value pairs assigned to the device. This metadata is not
     * interpreted or indexed by Cloud IoT Core. It can be used to add contextual
     * information for the device.
     *
     * Keys must conform to the regular expression [a-zA-Z][a-zA-Z0-9-_.+~%]+ and
     * be less than 128 bytes in length.
     *
     * Values are free-form strings. Each value must be less than or equal to 32
     * KB in size.
     *
     * The total size of all keys and values must be less than 256 KB, and the
     * maximum number of key-value pairs is 500.
     * </pre>
     *
     * <code>map&lt;string, string&gt; metadata = 17;</code>
     */
    @java.lang.Override
    public /* nullable */ java.lang.String getMetadataOrDefault(
        java.lang.String key,
        /* nullable */
        java.lang.String defaultValue) {
      if (key == null) {
        throw new NullPointerException("map key");
      }
      java.util.Map<java.lang.String, java.lang.String> map = internalGetMetadata().getMap();
      return map.containsKey(key) ? map.get(key) : defaultValue;
    }
    /**
     *
     *
     * <pre>
     * The metadata key-value pairs assigned to the device. This metadata is not
     * interpreted or indexed by Cloud IoT Core. It can be used to add contextual
     * information for the device.
     *
     * Keys must conform to the regular expression [a-zA-Z][a-zA-Z0-9-_.+~%]+ and
     * be less than 128 bytes in length.
     *
     * Values are free-form strings. Each value must be less than or equal to 32
     * KB in size.
     *
     * The total size of all keys and values must be less than 256 KB, and the
     * maximum number of key-value pairs is 500.
     * </pre>
     *
     * <code>map&lt;string, string&gt; metadata = 17;</code>
     */
    @java.lang.Override
    public java.lang.String getMetadataOrThrow(java.lang.String key) {
      if (key == null) {
        throw new NullPointerException("map key");
      }
      java.util.Map<java.lang.String, java.lang.String> map = internalGetMetadata().getMap();
      if (!map.containsKey(key)) {
        throw new java.lang.IllegalArgumentException();
      }
      return map.get(key);
    }

    public Builder clearMetadata() {
      bitField0_ = (bitField0_ & ~0x00008000);
      internalGetMutableMetadata().getMutableMap().clear();
      return this;
    }
    /**
     *
     *
     * <pre>
     * The metadata key-value pairs assigned to the device. This metadata is not
     * interpreted or indexed by Cloud IoT Core. It can be used to add contextual
     * information for the device.
     *
     * Keys must conform to the regular expression [a-zA-Z][a-zA-Z0-9-_.+~%]+ and
     * be less than 128 bytes in length.
     *
     * Values are free-form strings. Each value must be less than or equal to 32
     * KB in size.
     *
     * The total size of all keys and values must be less than 256 KB, and the
     * maximum number of key-value pairs is 500.
     * </pre>
     *
     * <code>map&lt;string, string&gt; metadata = 17;</code>
     */
    public Builder removeMetadata(java.lang.String key) {
      if (key == null) {
        throw new NullPointerException("map key");
      }
      internalGetMutableMetadata().getMutableMap().remove(key);
      return this;
    }
    /** Use alternate mutation accessors instead. */
    @java.lang.Deprecated
    public java.util.Map<java.lang.String, java.lang.String> getMutableMetadata() {
      bitField0_ |= 0x00008000;
      return internalGetMutableMetadata().getMutableMap();
    }
    /**
     *
     *
     * <pre>
     * The metadata key-value pairs assigned to the device. This metadata is not
     * interpreted or indexed by Cloud IoT Core. It can be used to add contextual
     * information for the device.
     *
     * Keys must conform to the regular expression [a-zA-Z][a-zA-Z0-9-_.+~%]+ and
     * be less than 128 bytes in length.
     *
     * Values are free-form strings. Each value must be less than or equal to 32
     * KB in size.
     *
     * The total size of all keys and values must be less than 256 KB, and the
     * maximum number of key-value pairs is 500.
     * </pre>
     *
     * <code>map&lt;string, string&gt; metadata = 17;</code>
     */
    public Builder putMetadata(java.lang.String key, java.lang.String value) {
      if (key == null) {
        throw new NullPointerException("map key");
      }
      if (value == null) {
        throw new NullPointerException("map value");
      }
      internalGetMutableMetadata().getMutableMap().put(key, value);
      bitField0_ |= 0x00008000;
      return this;
    }
    /**
     *
     *
     * <pre>
     * The metadata key-value pairs assigned to the device. This metadata is not
     * interpreted or indexed by Cloud IoT Core. It can be used to add contextual
     * information for the device.
     *
     * Keys must conform to the regular expression [a-zA-Z][a-zA-Z0-9-_.+~%]+ and
     * be less than 128 bytes in length.
     *
     * Values are free-form strings. Each value must be less than or equal to 32
     * KB in size.
     *
     * The total size of all keys and values must be less than 256 KB, and the
     * maximum number of key-value pairs is 500.
     * </pre>
     *
     * <code>map&lt;string, string&gt; metadata = 17;</code>
     */
    public Builder putAllMetadata(java.util.Map<java.lang.String, java.lang.String> values) {
      internalGetMutableMetadata().getMutableMap().putAll(values);
      bitField0_ |= 0x00008000;
      return this;
    }

    private com.google.cloud.iot.v1.GatewayConfig gatewayConfig_;
    private com.google.protobuf.SingleFieldBuilderV3<
            com.google.cloud.iot.v1.GatewayConfig,
            com.google.cloud.iot.v1.GatewayConfig.Builder,
            com.google.cloud.iot.v1.GatewayConfigOrBuilder>
        gatewayConfigBuilder_;
    /**
     *
     *
     * <pre>
     * Gateway-related configuration and state.
     * </pre>
     *
     * <code>.google.cloud.iot.v1.GatewayConfig gateway_config = 24;</code>
     *
     * @return Whether the gatewayConfig field is set.
     */
    public boolean hasGatewayConfig() {
      return ((bitField0_ & 0x00010000) != 0);
    }
    /**
     *
     *
     * <pre>
     * Gateway-related configuration and state.
     * </pre>
     *
     * <code>.google.cloud.iot.v1.GatewayConfig gateway_config = 24;</code>
     *
     * @return The gatewayConfig.
     */
    public com.google.cloud.iot.v1.GatewayConfig getGatewayConfig() {
      if (gatewayConfigBuilder_ == null) {
        return gatewayConfig_ == null
            ? com.google.cloud.iot.v1.GatewayConfig.getDefaultInstance()
            : gatewayConfig_;
      } else {
        return gatewayConfigBuilder_.getMessage();
      }
    }
    /**
     *
     *
     * <pre>
     * Gateway-related configuration and state.
     * </pre>
     *
     * <code>.google.cloud.iot.v1.GatewayConfig gateway_config = 24;</code>
     */
    public Builder setGatewayConfig(com.google.cloud.iot.v1.GatewayConfig value) {
      if (gatewayConfigBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        gatewayConfig_ = value;
      } else {
        gatewayConfigBuilder_.setMessage(value);
      }
      bitField0_ |= 0x00010000;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * Gateway-related configuration and state.
     * </pre>
     *
     * <code>.google.cloud.iot.v1.GatewayConfig gateway_config = 24;</code>
     */
    public Builder setGatewayConfig(com.google.cloud.iot.v1.GatewayConfig.Builder builderForValue) {
      if (gatewayConfigBuilder_ == null) {
        gatewayConfig_ = builderForValue.build();
      } else {
        gatewayConfigBuilder_.setMessage(builderForValue.build());
      }
      bitField0_ |= 0x00010000;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * Gateway-related configuration and state.
     * </pre>
     *
     * <code>.google.cloud.iot.v1.GatewayConfig gateway_config = 24;</code>
     */
    public Builder mergeGatewayConfig(com.google.cloud.iot.v1.GatewayConfig value) {
      if (gatewayConfigBuilder_ == null) {
        if (((bitField0_ & 0x00010000) != 0)
            && gatewayConfig_ != null
            && gatewayConfig_ != com.google.cloud.iot.v1.GatewayConfig.getDefaultInstance()) {
          getGatewayConfigBuilder().mergeFrom(value);
        } else {
          gatewayConfig_ = value;
        }
      } else {
        gatewayConfigBuilder_.mergeFrom(value);
      }
      bitField0_ |= 0x00010000;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * Gateway-related configuration and state.
     * </pre>
     *
     * <code>.google.cloud.iot.v1.GatewayConfig gateway_config = 24;</code>
     */
    public Builder clearGatewayConfig() {
      bitField0_ = (bitField0_ & ~0x00010000);
      gatewayConfig_ = null;
      if (gatewayConfigBuilder_ != null) {
        gatewayConfigBuilder_.dispose();
        gatewayConfigBuilder_ = null;
      }
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * Gateway-related configuration and state.
     * </pre>
     *
     * <code>.google.cloud.iot.v1.GatewayConfig gateway_config = 24;</code>
     */
    public com.google.cloud.iot.v1.GatewayConfig.Builder getGatewayConfigBuilder() {
      bitField0_ |= 0x00010000;
      onChanged();
      return getGatewayConfigFieldBuilder().getBuilder();
    }
    /**
     *
     *
     * <pre>
     * Gateway-related configuration and state.
     * </pre>
     *
     * <code>.google.cloud.iot.v1.GatewayConfig gateway_config = 24;</code>
     */
    public com.google.cloud.iot.v1.GatewayConfigOrBuilder getGatewayConfigOrBuilder() {
      if (gatewayConfigBuilder_ != null) {
        return gatewayConfigBuilder_.getMessageOrBuilder();
      } else {
        return gatewayConfig_ == null
            ? com.google.cloud.iot.v1.GatewayConfig.getDefaultInstance()
            : gatewayConfig_;
      }
    }
    /**
     *
     *
     * <pre>
     * Gateway-related configuration and state.
     * </pre>
     *
     * <code>.google.cloud.iot.v1.GatewayConfig gateway_config = 24;</code>
     */
    private com.google.protobuf.SingleFieldBuilderV3<
            com.google.cloud.iot.v1.GatewayConfig,
            com.google.cloud.iot.v1.GatewayConfig.Builder,
            com.google.cloud.iot.v1.GatewayConfigOrBuilder>
        getGatewayConfigFieldBuilder() {
      if (gatewayConfigBuilder_ == null) {
        gatewayConfigBuilder_ =
            new com.google.protobuf.SingleFieldBuilderV3<
                com.google.cloud.iot.v1.GatewayConfig,
                com.google.cloud.iot.v1.GatewayConfig.Builder,
                com.google.cloud.iot.v1.GatewayConfigOrBuilder>(
                getGatewayConfig(), getParentForChildren(), isClean());
        gatewayConfig_ = null;
      }
      return gatewayConfigBuilder_;
    }

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

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

    // @@protoc_insertion_point(builder_scope:google.cloud.iot.v1.Device)
  }

  // @@protoc_insertion_point(class_scope:google.cloud.iot.v1.Device)
  private static final com.google.cloud.iot.v1.Device DEFAULT_INSTANCE;

  static {
    DEFAULT_INSTANCE = new com.google.cloud.iot.v1.Device();
  }

  public static com.google.cloud.iot.v1.Device getDefaultInstance() {
    return DEFAULT_INSTANCE;
  }

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

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

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

  @java.lang.Override
  public com.google.cloud.iot.v1.Device getDefaultInstanceForType() {
    return DEFAULT_INSTANCE;
  }
}
