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

commonMain.protokt.v1.google.api.label.kt Maven / Gradle / Ivy

// Generated by protokt version 1.0.0-alpha.8. Do not modify.
// Source: google/api/label.proto
@file:Suppress("DEPRECATION")

package protokt.v1.google.api

import protokt.v1.AbstractKtDeserializer
import protokt.v1.AbstractKtMessage
import protokt.v1.KtBuilderDsl
import protokt.v1.KtEnum
import protokt.v1.KtEnumDeserializer
import protokt.v1.KtMessageDeserializer
import protokt.v1.KtMessageSerializer
import protokt.v1.SizeCodecs.sizeOf
import protokt.v1.UnknownFieldSet
import kotlin.Any
import kotlin.Boolean
import kotlin.Int
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.jvm.JvmStatic
import com.toasttab.protokt.rt.KtGeneratedMessage as RtKtGeneratedMessage
import protokt.v1.KtGeneratedMessage as V1KtGeneratedMessage

/**
 * A description of a label.
 */
@V1KtGeneratedMessage("google.api.LabelDescriptor")
@RtKtGeneratedMessage("google.api.LabelDescriptor")
public class LabelDescriptor private constructor(
  /**
   * The label key.
   */
  public val key: String,
  /**
   * The type of data that can be assigned to the label.
   */
  public val valueType: ValueType,
  /**
   * A human-readable description for the label.
   */
  public val description: String,
  public val unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
) : AbstractKtMessage() {
  override val messageSize: Int by lazy { messageSize() }

  private fun messageSize(): Int {
    var result = 0
    if (key.isNotEmpty()) {
      result += sizeOf(10u) + sizeOf(key)
    }
    if (valueType.value != 0) {
      result += sizeOf(16u) + sizeOf(valueType)
    }
    if (description.isNotEmpty()) {
      result += sizeOf(26u) + sizeOf(description)
    }
    result += unknownFields.size()
    return result
  }

  override fun serialize(serializer: KtMessageSerializer) {
    if (key.isNotEmpty()) {
      serializer.writeTag(10u).write(key)
    }
    if (valueType.value != 0) {
      serializer.writeTag(16u).write(valueType)
    }
    if (description.isNotEmpty()) {
      serializer.writeTag(26u).write(description)
    }
    serializer.writeUnknown(unknownFields)
  }

  override fun equals(other: Any?): Boolean =
    other is LabelDescriptor &&
      other.key == key &&
      other.valueType == valueType &&
      other.description == description &&
      other.unknownFields == unknownFields

  override fun hashCode(): Int {
    var result = unknownFields.hashCode()
    result = 31 * result + key.hashCode()
    result = 31 * result + valueType.hashCode()
    result = 31 * result + description.hashCode()
    return result
  }

  override fun toString(): String =
    "LabelDescriptor(" +
      "key=$key, " +
      "valueType=$valueType, " +
      "description=$description" +
      if (unknownFields.isEmpty()) ")" else ", unknownFields=$unknownFields)"

  public fun copy(builder: Builder.() -> Unit): LabelDescriptor =
    Builder().apply {
      key = [email protected]
      valueType = [email protected]
      description = [email protected]
      unknownFields = [email protected]
      builder()
    }.build()

  @KtBuilderDsl
  public class Builder {
    public var key: String = ""

    public var valueType: ValueType = ValueType.from(0)

    public var description: String = ""

    public var unknownFields: UnknownFieldSet = UnknownFieldSet.empty()

    public fun build(): LabelDescriptor =
      LabelDescriptor(
        key,
        valueType,
        description,
        unknownFields
      )
  }

  public companion object Deserializer : AbstractKtDeserializer() {
    @JvmStatic
    override fun deserialize(deserializer: KtMessageDeserializer): LabelDescriptor {
      var key = ""
      var valueType = ValueType.from(0)
      var description = ""
      var unknownFields: UnknownFieldSet.Builder? = null

      while (true) {
        when (deserializer.readTag()) {
          0 -> return LabelDescriptor(
            key,
            valueType,
            description,
            UnknownFieldSet.from(unknownFields)
          )
          10 -> key = deserializer.readString()
          16 -> valueType = deserializer.readEnum(ValueType)
          26 -> description = deserializer.readString()
          else ->
            unknownFields =
              (unknownFields ?: UnknownFieldSet.Builder()).also {
                it.add(deserializer.readUnknown())
              }
        }
      }
    }

    @JvmStatic
    public operator fun invoke(dsl: Builder.() -> Unit): LabelDescriptor = Builder().apply(dsl).build()
  }

  /**
   * Value types that can be used as label values.
   */
  public sealed class ValueType(
    override val `value`: Int,
    override val name: String
  ) : KtEnum() {
    /**
     * A variable-length string. This is the default.
     */
    public object STRING : ValueType(0, "STRING")

    /**
     * Boolean; true or false.
     */
    public object BOOL : ValueType(1, "BOOL")

    /**
     * A 64-bit signed integer.
     */
    public object INT64 : ValueType(2, "INT64")

    public class UNRECOGNIZED(
      `value`: Int
    ) : ValueType(value, "UNRECOGNIZED")

    public companion object Deserializer : KtEnumDeserializer {
      override fun from(`value`: Int): ValueType =
        when (value) {
          0 -> STRING
          1 -> BOOL
          2 -> INT64
          else -> UNRECOGNIZED(value)
        }
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy