All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.worker.Heartbeat.kt Maven / Gradle / Ivy

Go to download

KMP package which exports compiled protobuf entities to be used by other repos

There is a newer version: 2.89.0
Show newest version
// Code generated by Wire protocol buffer compiler, do not edit.
// Source: worker.Heartbeat in worker/worker.proto
package worker

import com.squareup.wire.EnumAdapter
import com.squareup.wire.FieldEncoding
import com.squareup.wire.Message
import com.squareup.wire.ProtoAdapter
import com.squareup.wire.ProtoReader
import com.squareup.wire.ProtoWriter
import com.squareup.wire.ReverseProtoWriter
import com.squareup.wire.Syntax
import com.squareup.wire.Syntax.PROTO_3
import com.squareup.wire.WireEnum
import com.squareup.wire.WireField
import com.squareup.wire.`internal`.sanitize
import kotlin.Any
import kotlin.AssertionError
import kotlin.Boolean
import kotlin.Deprecated
import kotlin.DeprecationLevel
import kotlin.Int
import kotlin.Long
import kotlin.Nothing
import kotlin.String
import kotlin.Unit
import okio.ByteString

public class Heartbeat(
  @field:WireField(
    tag = 1,
    adapter = "com.squareup.wire.ProtoAdapter#STRING",
    label = WireField.Label.OMIT_IDENTITY,
  )
  public val timestamp: String = "",
  @field:WireField(
    tag = 2,
    adapter = "worker.Heartbeat${'$'}ServingStatus#ADAPTER",
    label = WireField.Label.OMIT_IDENTITY,
  )
  public val status: ServingStatus = ServingStatus.SERVING_STATUS_UNKNOWN,
  unknownFields: ByteString = ByteString.EMPTY,
) : Message(ADAPTER, unknownFields) {
  @Deprecated(
    message = "Shouldn't be used in Kotlin",
    level = DeprecationLevel.HIDDEN,
  )
  public override fun newBuilder(): Nothing = throw
      AssertionError("Builders are deprecated and only available in a javaInterop build; see https://square.github.io/wire/wire_compiler/#kotlin")

  public override fun equals(other: Any?): Boolean {
    if (other === this) return true
    if (other !is Heartbeat) return false
    if (unknownFields != other.unknownFields) return false
    if (timestamp != other.timestamp) return false
    if (status != other.status) return false
    return true
  }

  public override fun hashCode(): Int {
    var result = super.hashCode
    if (result == 0) {
      result = unknownFields.hashCode()
      result = result * 37 + timestamp.hashCode()
      result = result * 37 + status.hashCode()
      super.hashCode = result
    }
    return result
  }

  public override fun toString(): String {
    val result = mutableListOf()
    result += """timestamp=${sanitize(timestamp)}"""
    result += """status=$status"""
    return result.joinToString(prefix = "Heartbeat{", separator = ", ", postfix = "}")
  }

  public fun copy(
    timestamp: String = this.timestamp,
    status: ServingStatus = this.status,
    unknownFields: ByteString = this.unknownFields,
  ): Heartbeat = Heartbeat(timestamp, status, unknownFields)

  public companion object {
    public val ADAPTER: ProtoAdapter = object : ProtoAdapter(
      FieldEncoding.LENGTH_DELIMITED, 
      Heartbeat::class, 
      "type.googleapis.com/worker.Heartbeat", 
      PROTO_3, 
      null, 
      "worker/worker.proto"
    ) {
      public override fun encodedSize(`value`: Heartbeat): Int {
        var size = value.unknownFields.size
        if (value.timestamp != "") size += ProtoAdapter.STRING.encodedSizeWithTag(1,
            value.timestamp)
        if (value.status != ServingStatus.SERVING_STATUS_UNKNOWN) size +=
            ServingStatus.ADAPTER.encodedSizeWithTag(2, value.status)
        return size
      }

      public override fun encode(writer: ProtoWriter, `value`: Heartbeat): Unit {
        if (value.timestamp != "") ProtoAdapter.STRING.encodeWithTag(writer, 1, value.timestamp)
        if (value.status != ServingStatus.SERVING_STATUS_UNKNOWN)
            ServingStatus.ADAPTER.encodeWithTag(writer, 2, value.status)
        writer.writeBytes(value.unknownFields)
      }

      public override fun encode(writer: ReverseProtoWriter, `value`: Heartbeat): Unit {
        writer.writeBytes(value.unknownFields)
        if (value.status != ServingStatus.SERVING_STATUS_UNKNOWN)
            ServingStatus.ADAPTER.encodeWithTag(writer, 2, value.status)
        if (value.timestamp != "") ProtoAdapter.STRING.encodeWithTag(writer, 1, value.timestamp)
      }

      public override fun decode(reader: ProtoReader): Heartbeat {
        var timestamp: String = ""
        var status: ServingStatus = ServingStatus.SERVING_STATUS_UNKNOWN
        val unknownFields = reader.forEachTag { tag ->
          when (tag) {
            1 -> timestamp = ProtoAdapter.STRING.decode(reader)
            2 -> try {
              status = ServingStatus.ADAPTER.decode(reader)
            } catch (e: ProtoAdapter.EnumConstantNotFoundException) {
              reader.addUnknownField(tag, FieldEncoding.VARINT, e.value.toLong())
            }
            else -> reader.readUnknownField(tag)
          }
        }
        return Heartbeat(
          timestamp = timestamp,
          status = status,
          unknownFields = unknownFields
        )
      }

      public override fun redact(`value`: Heartbeat): Heartbeat = value.copy(
        unknownFields = ByteString.EMPTY
      )
    }

    private const val serialVersionUID: Long = 0L
  }

  public enum class ServingStatus(
    public override val `value`: Int,
  ) : WireEnum {
    SERVING_STATUS_UNKNOWN(0),
    SERVING_STATUS_SERVING(1),
    SERVING_STATUS_NOT_SERVING(2),
    ;

    public companion object {
      public val ADAPTER: ProtoAdapter = object : EnumAdapter(
        ServingStatus::class, 
        PROTO_3, 
        ServingStatus.SERVING_STATUS_UNKNOWN
      ) {
        public override fun fromValue(`value`: Int): ServingStatus? = ServingStatus.fromValue(value)
      }

      public fun fromValue(`value`: Int): ServingStatus? = when (value) {
        0 -> SERVING_STATUS_UNKNOWN
        1 -> SERVING_STATUS_SERVING
        2 -> SERVING_STATUS_NOT_SERVING
        else -> null
      }
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy