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

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

The newest version!
// Generated by protokt version 1.0.0-beta.2. Do not modify.
// Source: google/api/log.proto
@file:Suppress("DEPRECATION")

package protokt.v1.google.api

import protokt.v1.AbstractDeserializer
import protokt.v1.AbstractMessage
import protokt.v1.BuilderDsl
import protokt.v1.Collections.copyList
import protokt.v1.Collections.unmodifiableList
import protokt.v1.GeneratedMessage
import protokt.v1.GeneratedProperty
import protokt.v1.Reader
import protokt.v1.SizeCodecs.sizeOf
import protokt.v1.UnknownFieldSet
import protokt.v1.Writer
import kotlin.Any
import kotlin.Boolean
import kotlin.Int
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.MutableList
import kotlin.jvm.JvmStatic

/**
 * A description of a log type. Example in YAML format:
 *
 *      - name: library.googleapis.com/activity_history       description: The history of borrowing
 * and returning library items.       display_name: Activity       labels:       - key: /customer_id
 *      description: Identifier of a library customer
 */
@GeneratedMessage("google.api.LogDescriptor")
public class LogDescriptor private constructor(
  /**
   * The name of the log. It must be less than 512 characters long and can include the following
   * characters: upper- and lower-case alphanumeric characters [A-Za-z0-9], and punctuation characters
   * including slash, underscore, hyphen, period [/_-.].
   */
  @GeneratedProperty(1)
  public val name: String,
  /**
   * The set of labels that are available to describe a specific log entry. Runtime requests that
   * contain labels not specified here are considered invalid.
   */
  @GeneratedProperty(2)
  public val labels: List,
  /**
   * A human-readable description of this log. This information appears in the documentation and can
   * contain details.
   */
  @GeneratedProperty(3)
  public val description: String,
  /**
   * The human-readable name for this log. This information appears on the user interface and should
   * be concise.
   */
  @GeneratedProperty(4)
  public val displayName: String,
  public val unknownFields: UnknownFieldSet = UnknownFieldSet.empty()
) : AbstractMessage() {
  private val `$messageSize`: Int by lazy {
    var result = 0
    if (name.isNotEmpty()) {
      result += sizeOf(10u) + sizeOf(name)
    }
    if (labels.isNotEmpty()) {
      result += (sizeOf(18u) * labels.size) + labels.sumOf { sizeOf(it) }
    }
    if (description.isNotEmpty()) {
      result += sizeOf(26u) + sizeOf(description)
    }
    if (displayName.isNotEmpty()) {
      result += sizeOf(34u) + sizeOf(displayName)
    }
    result += unknownFields.size()
    result
  }

  override fun messageSize(): Int = `$messageSize`

  override fun serialize(writer: Writer) {
    if (name.isNotEmpty()) {
      writer.writeTag(10u).write(name)
    }
    labels.forEach { writer.writeTag(18u).write(it) }
    if (description.isNotEmpty()) {
      writer.writeTag(26u).write(description)
    }
    if (displayName.isNotEmpty()) {
      writer.writeTag(34u).write(displayName)
    }
    writer.writeUnknown(unknownFields)
  }

  override fun equals(other: Any?): Boolean =
    other is LogDescriptor &&
      other.name == name &&
      other.labels == labels &&
      other.description == description &&
      other.displayName == displayName &&
      other.unknownFields == unknownFields

  override fun hashCode(): Int {
    var result = unknownFields.hashCode()
    result = 31 * result + name.hashCode()
    result = 31 * result + labels.hashCode()
    result = 31 * result + description.hashCode()
    result = 31 * result + displayName.hashCode()
    return result
  }

  override fun toString(): String =
    "LogDescriptor(" +
      "name=$name, " +
      "labels=$labels, " +
      "description=$description, " +
      "displayName=$displayName" +
      if (unknownFields.isEmpty()) ")" else ", unknownFields=$unknownFields)"

  public fun copy(builder: Builder.() -> Unit): LogDescriptor =
    Builder().apply {
      name = [email protected]
      labels = [email protected]
      description = [email protected]
      displayName = [email protected]
      unknownFields = [email protected]
      builder()
    }.build()

  @BuilderDsl
  public class Builder {
    public var name: String = ""

    public var labels: List = emptyList()
      set(newValue) {
        field = copyList(newValue)
      }

    public var description: String = ""

    public var displayName: String = ""

    public var unknownFields: UnknownFieldSet = UnknownFieldSet.empty()

    public fun build(): LogDescriptor =
      LogDescriptor(
        name,
        unmodifiableList(labels),
        description,
        displayName,
        unknownFields
      )
  }

  public companion object Deserializer : AbstractDeserializer() {
    @JvmStatic
    override fun deserialize(reader: Reader): LogDescriptor {
      var name = ""
      var labels: MutableList? = null
      var description = ""
      var displayName = ""
      var unknownFields: UnknownFieldSet.Builder? = null

      while (true) {
        when (reader.readTag()) {
          0u -> return LogDescriptor(
            name,
            unmodifiableList(labels),
            description,
            displayName,
            UnknownFieldSet.from(unknownFields)
          )
          10u -> name = reader.readString()
          18u ->
            labels =
              (labels ?: mutableListOf()).apply {
                reader.readRepeated(false) {
                  add(reader.readMessage(LabelDescriptor))
                }
              }
          26u -> description = reader.readString()
          34u -> displayName = reader.readString()
          else ->
            unknownFields =
              (unknownFields ?: UnknownFieldSet.Builder()).also {
                it.add(reader.readUnknown())
              }
        }
      }
    }

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy