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

org.whispersystems.signalservice.internal.push.BodyRange.kt Maven / Gradle / Ivy

There is a newer version: 2.15.3_unofficial_107
Show newest version
// Code generated by Wire protocol buffer compiler, do not edit.
// Source: signalservice.BodyRange in SignalService.proto
package org.whispersystems.signalservice.`internal`.push

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_2
import com.squareup.wire.WireEnum
import com.squareup.wire.WireField
import com.squareup.wire.`internal`.countNonDefa
import com.squareup.wire.`internal`.sanitize
import kotlin.Any
import kotlin.Boolean
import kotlin.Int
import kotlin.Long
import kotlin.String
import kotlin.Unit
import kotlin.jvm.JvmField
import kotlin.jvm.JvmStatic
import okio.ByteString

public class BodyRange(
  @field:WireField(
    tag = 1,
    adapter = "com.squareup.wire.ProtoAdapter#UINT32",
  )
  @JvmField
  public val start: Int? = null,
  @field:WireField(
    tag = 2,
    adapter = "com.squareup.wire.ProtoAdapter#UINT32",
  )
  @JvmField
  public val length: Int? = null,
  @field:WireField(
    tag = 3,
    adapter = "com.squareup.wire.ProtoAdapter#STRING",
    oneofName = "associatedValue",
  )
  @JvmField
  public val mentionAci: String? = null,
  @field:WireField(
    tag = 4,
    adapter = "org.whispersystems.signalservice.internal.push.BodyRange${'$'}Style#ADAPTER",
    oneofName = "associatedValue",
  )
  @JvmField
  public val style: Style? = null,
  unknownFields: ByteString = ByteString.EMPTY,
) : Message(ADAPTER, unknownFields) {
  init {
    require(countNonDefa(mentionAci, style) <= 1) {
      "At most one of mentionAci, style may be non-null"
    }
  }

  public override fun newBuilder(): Builder {
    val builder = Builder()
    builder.start = start
    builder.length = length
    builder.mentionAci = mentionAci
    builder.style = style
    builder.addUnknownFields(unknownFields)
    return builder
  }

  public override fun equals(other: Any?): Boolean {
    if (other === this) return true
    if (other !is BodyRange) return false
    if (unknownFields != other.unknownFields) return false
    if (start != other.start) return false
    if (length != other.length) return false
    if (mentionAci != other.mentionAci) return false
    if (style != other.style) return false
    return true
  }

  public override fun hashCode(): Int {
    var result = super.hashCode
    if (result == 0) {
      result = unknownFields.hashCode()
      result = result * 37 + (start?.hashCode() ?: 0)
      result = result * 37 + (length?.hashCode() ?: 0)
      result = result * 37 + (mentionAci?.hashCode() ?: 0)
      result = result * 37 + (style?.hashCode() ?: 0)
      super.hashCode = result
    }
    return result
  }

  public override fun toString(): String {
    val result = mutableListOf()
    if (start != null) result += """start=$start"""
    if (length != null) result += """length=$length"""
    if (mentionAci != null) result += """mentionAci=${sanitize(mentionAci)}"""
    if (style != null) result += """style=$style"""
    return result.joinToString(prefix = "BodyRange{", separator = ", ", postfix = "}")
  }

  public fun copy(
    start: Int? = this.start,
    length: Int? = this.length,
    mentionAci: String? = this.mentionAci,
    style: Style? = this.style,
    unknownFields: ByteString = this.unknownFields,
  ): BodyRange = BodyRange(start, length, mentionAci, style, unknownFields)

  public class Builder : Message.Builder() {
    @JvmField
    public var start: Int? = null

    @JvmField
    public var length: Int? = null

    @JvmField
    public var mentionAci: String? = null

    @JvmField
    public var style: Style? = null

    public fun start(start: Int?): Builder {
      this.start = start
      return this
    }

    public fun length(length: Int?): Builder {
      this.length = length
      return this
    }

    public fun mentionAci(mentionAci: String?): Builder {
      this.mentionAci = mentionAci
      this.style = null
      return this
    }

    public fun style(style: Style?): Builder {
      this.style = style
      this.mentionAci = null
      return this
    }

    public override fun build(): BodyRange = BodyRange(
      start = start,
      length = length,
      mentionAci = mentionAci,
      style = style,
      unknownFields = buildUnknownFields()
    )
  }

  public companion object {
    @JvmField
    public val ADAPTER: ProtoAdapter = object : ProtoAdapter(
      FieldEncoding.LENGTH_DELIMITED, 
      BodyRange::class, 
      "type.googleapis.com/signalservice.BodyRange", 
      PROTO_2, 
      null, 
      "SignalService.proto"
    ) {
      public override fun encodedSize(`value`: BodyRange): Int {
        var size = value.unknownFields.size
        size += ProtoAdapter.UINT32.encodedSizeWithTag(1, value.start)
        size += ProtoAdapter.UINT32.encodedSizeWithTag(2, value.length)
        size += ProtoAdapter.STRING.encodedSizeWithTag(3, value.mentionAci)
        size += Style.ADAPTER.encodedSizeWithTag(4, value.style)
        return size
      }

      public override fun encode(writer: ProtoWriter, `value`: BodyRange): Unit {
        ProtoAdapter.UINT32.encodeWithTag(writer, 1, value.start)
        ProtoAdapter.UINT32.encodeWithTag(writer, 2, value.length)
        ProtoAdapter.STRING.encodeWithTag(writer, 3, value.mentionAci)
        Style.ADAPTER.encodeWithTag(writer, 4, value.style)
        writer.writeBytes(value.unknownFields)
      }

      public override fun encode(writer: ReverseProtoWriter, `value`: BodyRange): Unit {
        writer.writeBytes(value.unknownFields)
        Style.ADAPTER.encodeWithTag(writer, 4, value.style)
        ProtoAdapter.STRING.encodeWithTag(writer, 3, value.mentionAci)
        ProtoAdapter.UINT32.encodeWithTag(writer, 2, value.length)
        ProtoAdapter.UINT32.encodeWithTag(writer, 1, value.start)
      }

      public override fun decode(reader: ProtoReader): BodyRange {
        var start: Int? = null
        var length: Int? = null
        var mentionAci: String? = null
        var style: Style? = null
        val unknownFields = reader.forEachTag { tag ->
          when (tag) {
            1 -> start = ProtoAdapter.UINT32.decode(reader)
            2 -> length = ProtoAdapter.UINT32.decode(reader)
            3 -> mentionAci = ProtoAdapter.STRING.decode(reader)
            4 -> try {
              style = Style.ADAPTER.decode(reader)
            } catch (e: ProtoAdapter.EnumConstantNotFoundException) {
              reader.addUnknownField(tag, FieldEncoding.VARINT, e.value.toLong())
            }
            else -> reader.readUnknownField(tag)
          }
        }
        return BodyRange(
          start = start,
          length = length,
          mentionAci = mentionAci,
          style = style,
          unknownFields = unknownFields
        )
      }

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

    private const val serialVersionUID: Long = 0L
  }

  public enum class Style(
    public override val `value`: Int,
  ) : WireEnum {
    NONE(0),
    BOLD(1),
    ITALIC(2),
    SPOILER(3),
    STRIKETHROUGH(4),
    MONOSPACE(5),
    ;

    public companion object {
      @JvmField
      public val ADAPTER: ProtoAdapter