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

protokt.com.google.api.log.kt Maven / Gradle / Ivy

There is a newer version: 0.12.1
Show newest version
// Generated by protokt version 0.12.0. Do not modify.
// Source: google/api/log.proto
package com.google.api

import com.toasttab.protokt.rt.KtDeserializer
import com.toasttab.protokt.rt.KtGeneratedMessage
import com.toasttab.protokt.rt.KtMessage
import com.toasttab.protokt.rt.KtMessageDeserializer
import com.toasttab.protokt.rt.KtMessageSerializer
import com.toasttab.protokt.rt.Tag
import com.toasttab.protokt.rt.UnknownFieldSet
import com.toasttab.protokt.rt.copyList
import com.toasttab.protokt.rt.finishList
import com.toasttab.protokt.rt.sizeof
import kotlin.Any
import kotlin.Boolean
import kotlin.Int
import kotlin.String
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.MutableList

/**
 * 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
 */
@KtGeneratedMessage("google.api.LogDescriptor")
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 [/_-.].
     */
    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.
     */
    val labels: List,
    /**
     * A human-readable description of this log. This information appears in the documentation and
     * can contain details.
     */
    val description: String,
    /**
     * The human-readable name for this log. This information appears on the user interface and
     * should be concise.
     */
    val displayName: String,
    val unknownFields: UnknownFieldSet = UnknownFieldSet.empty(),
) : KtMessage {
    override val messageSize: Int by lazy { messageSize() }

    private fun messageSize(): Int {
        var result = 0
        if (name.isNotEmpty()) {
            result += sizeof(Tag(1)) + sizeof(name) 
        }
        if (labels.isNotEmpty()) {
            result += (sizeof(Tag(2)) * labels.size) + labels.sumOf { sizeof(it) } 
        }
        if (description.isNotEmpty()) {
            result += sizeof(Tag(3)) + sizeof(description) 
        }
        if (displayName.isNotEmpty()) {
            result += sizeof(Tag(4)) + sizeof(displayName) 
        }
        result += unknownFields.size()
        return result
    }

    override fun serialize(serializer: KtMessageSerializer) {
        if (name.isNotEmpty()) {
            serializer.write(Tag(10)).write(name)
        }
        if (labels.isNotEmpty()) {
            labels.forEach { serializer.write(Tag(18)).write(it) }
        }
        if (description.isNotEmpty()) {
            serializer.write(Tag(26)).write(description)
        }
        if (displayName.isNotEmpty()) {
            serializer.write(Tag(34)).write(displayName)
        }
        serializer.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"})"

    fun copy(dsl: LogDescriptorDsl.() -> Unit): LogDescriptor = LogDescriptor.Deserializer {
        name = [email protected]
        labels = [email protected]
        description = [email protected]
        displayName = [email protected]
        unknownFields = [email protected]
        dsl()
    }

    class LogDescriptorDsl {
        var name: String = ""

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

        var description: String = ""

        var displayName: String = ""

        var unknownFields: UnknownFieldSet = UnknownFieldSet.empty()

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

    companion object Deserializer : KtDeserializer,
            (LogDescriptorDsl.() -> Unit) -> LogDescriptor {
        override fun deserialize(deserializer: KtMessageDeserializer): LogDescriptor {
            var name = ""
            var labels : MutableList? = null
            var description = ""
            var displayName = ""
            var unknownFields: UnknownFieldSet.Builder? = null
            while (true) {
                when(deserializer.readTag()) {
                    0 -> return LogDescriptor(name,
                            finishList(labels),
                            description,
                            displayName,
                            UnknownFieldSet.from(unknownFields))
                    10 -> name = deserializer.readString()
                    18 -> labels = (labels ?: mutableListOf()).apply {
                                   deserializer.readRepeated(false) {
                                       add(deserializer.readMessage(com.google.api.LabelDescriptor))
                                   }
                               }
                    26 -> description = deserializer.readString()
                    34 -> displayName = deserializer.readString()
                    else -> unknownFields = (unknownFields ?:
                            UnknownFieldSet.Builder()).also {it.add(deserializer.readUnknown()) }
                }
            }
        }

        override fun invoke(dsl: LogDescriptorDsl.() -> Unit): LogDescriptor =
                LogDescriptorDsl().apply(dsl).build()
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy