org.whispersystems.signalservice.internal.websocket.WebSocketMessage.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of signal-service-java Show documentation
Show all versions of signal-service-java Show documentation
Signal Service communication library for Java, unofficial fork
// Code generated by Wire protocol buffer compiler, do not edit.
// Source: signalservice.WebSocketMessage in WebSocketResources.proto
package org.whispersystems.signalservice.`internal`.websocket
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 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 WebSocketMessage(
@field:WireField(
tag = 1,
adapter =
"org.whispersystems.signalservice.internal.websocket.WebSocketMessage${'$'}Type#ADAPTER",
)
@JvmField
public val type: Type? = null,
@field:WireField(
tag = 2,
adapter = "org.whispersystems.signalservice.internal.websocket.WebSocketRequestMessage#ADAPTER",
)
@JvmField
public val request: WebSocketRequestMessage? = null,
@field:WireField(
tag = 3,
adapter =
"org.whispersystems.signalservice.internal.websocket.WebSocketResponseMessage#ADAPTER",
)
@JvmField
public val response: WebSocketResponseMessage? = null,
unknownFields: ByteString = ByteString.EMPTY,
) : Message(ADAPTER, unknownFields) {
public override fun newBuilder(): Builder {
val builder = Builder()
builder.type = type
builder.request = request
builder.response = response
builder.addUnknownFields(unknownFields)
return builder
}
public override fun equals(other: Any?): Boolean {
if (other === this) return true
if (other !is WebSocketMessage) return false
if (unknownFields != other.unknownFields) return false
if (type != other.type) return false
if (request != other.request) return false
if (response != other.response) return false
return true
}
public override fun hashCode(): Int {
var result = super.hashCode
if (result == 0) {
result = unknownFields.hashCode()
result = result * 37 + (type?.hashCode() ?: 0)
result = result * 37 + (request?.hashCode() ?: 0)
result = result * 37 + (response?.hashCode() ?: 0)
super.hashCode = result
}
return result
}
public override fun toString(): String {
val result = mutableListOf()
if (type != null) result += """type=$type"""
if (request != null) result += """request=$request"""
if (response != null) result += """response=$response"""
return result.joinToString(prefix = "WebSocketMessage{", separator = ", ", postfix = "}")
}
public fun copy(
type: Type? = this.type,
request: WebSocketRequestMessage? = this.request,
response: WebSocketResponseMessage? = this.response,
unknownFields: ByteString = this.unknownFields,
): WebSocketMessage = WebSocketMessage(type, request, response, unknownFields)
public class Builder : Message.Builder() {
@JvmField
public var type: Type? = null
@JvmField
public var request: WebSocketRequestMessage? = null
@JvmField
public var response: WebSocketResponseMessage? = null
public fun type(type: Type?): Builder {
this.type = type
return this
}
public fun request(request: WebSocketRequestMessage?): Builder {
this.request = request
return this
}
public fun response(response: WebSocketResponseMessage?): Builder {
this.response = response
return this
}
public override fun build(): WebSocketMessage = WebSocketMessage(
type = type,
request = request,
response = response,
unknownFields = buildUnknownFields()
)
}
public companion object {
@JvmField
public val ADAPTER: ProtoAdapter = object : ProtoAdapter(
FieldEncoding.LENGTH_DELIMITED,
WebSocketMessage::class,
"type.googleapis.com/signalservice.WebSocketMessage",
PROTO_2,
null,
"WebSocketResources.proto"
) {
public override fun encodedSize(`value`: WebSocketMessage): Int {
var size = value.unknownFields.size
size += Type.ADAPTER.encodedSizeWithTag(1, value.type)
size += WebSocketRequestMessage.ADAPTER.encodedSizeWithTag(2, value.request)
size += WebSocketResponseMessage.ADAPTER.encodedSizeWithTag(3, value.response)
return size
}
public override fun encode(writer: ProtoWriter, `value`: WebSocketMessage): Unit {
Type.ADAPTER.encodeWithTag(writer, 1, value.type)
WebSocketRequestMessage.ADAPTER.encodeWithTag(writer, 2, value.request)
WebSocketResponseMessage.ADAPTER.encodeWithTag(writer, 3, value.response)
writer.writeBytes(value.unknownFields)
}
public override fun encode(writer: ReverseProtoWriter, `value`: WebSocketMessage): Unit {
writer.writeBytes(value.unknownFields)
WebSocketResponseMessage.ADAPTER.encodeWithTag(writer, 3, value.response)
WebSocketRequestMessage.ADAPTER.encodeWithTag(writer, 2, value.request)
Type.ADAPTER.encodeWithTag(writer, 1, value.type)
}
public override fun decode(reader: ProtoReader): WebSocketMessage {
var type: Type? = null
var request: WebSocketRequestMessage? = null
var response: WebSocketResponseMessage? = null
val unknownFields = reader.forEachTag { tag ->
when (tag) {
1 -> try {
type = Type.ADAPTER.decode(reader)
} catch (e: ProtoAdapter.EnumConstantNotFoundException) {
reader.addUnknownField(tag, FieldEncoding.VARINT, e.value.toLong())
}
2 -> request = WebSocketRequestMessage.ADAPTER.decode(reader)
3 -> response = WebSocketResponseMessage.ADAPTER.decode(reader)
else -> reader.readUnknownField(tag)
}
}
return WebSocketMessage(
type = type,
request = request,
response = response,
unknownFields = unknownFields
)
}
public override fun redact(`value`: WebSocketMessage): WebSocketMessage = value.copy(
request = value.request?.let(WebSocketRequestMessage.ADAPTER::redact),
response = value.response?.let(WebSocketResponseMessage.ADAPTER::redact),
unknownFields = ByteString.EMPTY
)
}
private const val serialVersionUID: Long = 0L
}
public enum class Type(
public override val `value`: Int,
) : WireEnum {
UNKNOWN(0),
REQUEST(1),
RESPONSE(2),
;
public companion object {
@JvmField
public val ADAPTER: ProtoAdapter = object : EnumAdapter(
Type::class,
PROTO_2,
Type.UNKNOWN
) {
public override fun fromValue(`value`: Int): Type? = Type.fromValue(value)
}
@JvmStatic
public fun fromValue(`value`: Int): Type? = when (value) {
0 -> UNKNOWN
1 -> REQUEST
2 -> RESPONSE
else -> null
}
}
}
}