org.whispersystems.signalservice.internal.push.TextAttachment.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.TextAttachment 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`.checkElementsNotNull
import com.squareup.wire.`internal`.countNonDefa
import com.squareup.wire.`internal`.immutableCopyOf
import com.squareup.wire.`internal`.sanitize
import kotlin.Any
import kotlin.Boolean
import kotlin.Float
import kotlin.Int
import kotlin.Long
import kotlin.String
import kotlin.Unit
import kotlin.collections.List
import kotlin.jvm.JvmField
import kotlin.jvm.JvmStatic
import okio.ByteString
public class TextAttachment(
@field:WireField(
tag = 1,
adapter = "com.squareup.wire.ProtoAdapter#STRING",
)
@JvmField
public val text: String? = null,
@field:WireField(
tag = 2,
adapter = "org.whispersystems.signalservice.internal.push.TextAttachment${'$'}Style#ADAPTER",
)
@JvmField
public val textStyle: Style? = null,
/**
* integer representation of hex color
*/
@field:WireField(
tag = 3,
adapter = "com.squareup.wire.ProtoAdapter#UINT32",
)
@JvmField
public val textForegroundColor: Int? = null,
@field:WireField(
tag = 4,
adapter = "com.squareup.wire.ProtoAdapter#UINT32",
)
@JvmField
public val textBackgroundColor: Int? = null,
@field:WireField(
tag = 5,
adapter = "org.whispersystems.signalservice.internal.push.Preview#ADAPTER",
)
@JvmField
public val preview: Preview? = null,
@field:WireField(
tag = 6,
adapter = "org.whispersystems.signalservice.internal.push.TextAttachment${'$'}Gradient#ADAPTER",
oneofName = "background",
)
@JvmField
public val gradient: Gradient? = null,
@field:WireField(
tag = 7,
adapter = "com.squareup.wire.ProtoAdapter#UINT32",
oneofName = "background",
)
@JvmField
public val color: Int? = null,
unknownFields: ByteString = ByteString.EMPTY,
) : Message(ADAPTER, unknownFields) {
init {
require(countNonDefa(gradient, color) <= 1) {
"At most one of gradient, color may be non-null"
}
}
public override fun newBuilder(): Builder {
val builder = Builder()
builder.text = text
builder.textStyle = textStyle
builder.textForegroundColor = textForegroundColor
builder.textBackgroundColor = textBackgroundColor
builder.preview = preview
builder.gradient = gradient
builder.color = color
builder.addUnknownFields(unknownFields)
return builder
}
public override fun equals(other: Any?): Boolean {
if (other === this) return true
if (other !is TextAttachment) return false
if (unknownFields != other.unknownFields) return false
if (text != other.text) return false
if (textStyle != other.textStyle) return false
if (textForegroundColor != other.textForegroundColor) return false
if (textBackgroundColor != other.textBackgroundColor) return false
if (preview != other.preview) return false
if (gradient != other.gradient) return false
if (color != other.color) return false
return true
}
public override fun hashCode(): Int {
var result = super.hashCode
if (result == 0) {
result = unknownFields.hashCode()
result = result * 37 + (text?.hashCode() ?: 0)
result = result * 37 + (textStyle?.hashCode() ?: 0)
result = result * 37 + (textForegroundColor?.hashCode() ?: 0)
result = result * 37 + (textBackgroundColor?.hashCode() ?: 0)
result = result * 37 + (preview?.hashCode() ?: 0)
result = result * 37 + (gradient?.hashCode() ?: 0)
result = result * 37 + (color?.hashCode() ?: 0)
super.hashCode = result
}
return result
}
public override fun toString(): String {
val result = mutableListOf()
if (text != null) result += """text=${sanitize(text)}"""
if (textStyle != null) result += """textStyle=$textStyle"""
if (textForegroundColor != null) result += """textForegroundColor=$textForegroundColor"""
if (textBackgroundColor != null) result += """textBackgroundColor=$textBackgroundColor"""
if (preview != null) result += """preview=$preview"""
if (gradient != null) result += """gradient=$gradient"""
if (color != null) result += """color=$color"""
return result.joinToString(prefix = "TextAttachment{", separator = ", ", postfix = "}")
}
public fun copy(
text: String? = this.text,
textStyle: Style? = this.textStyle,
textForegroundColor: Int? = this.textForegroundColor,
textBackgroundColor: Int? = this.textBackgroundColor,
preview: Preview? = this.preview,
gradient: Gradient? = this.gradient,
color: Int? = this.color,
unknownFields: ByteString = this.unknownFields,
): TextAttachment = TextAttachment(text, textStyle, textForegroundColor, textBackgroundColor,
preview, gradient, color, unknownFields)
public class Builder : Message.Builder() {
@JvmField
public var text: String? = null
@JvmField
public var textStyle: Style? = null
@JvmField
public var textForegroundColor: Int? = null
@JvmField
public var textBackgroundColor: Int? = null
@JvmField
public var preview: Preview? = null
@JvmField
public var gradient: Gradient? = null
@JvmField
public var color: Int? = null
public fun text(text: String?): Builder {
this.text = text
return this
}
public fun textStyle(textStyle: Style?): Builder {
this.textStyle = textStyle
return this
}
/**
* integer representation of hex color
*/
public fun textForegroundColor(textForegroundColor: Int?): Builder {
this.textForegroundColor = textForegroundColor
return this
}
public fun textBackgroundColor(textBackgroundColor: Int?): Builder {
this.textBackgroundColor = textBackgroundColor
return this
}
public fun preview(preview: Preview?): Builder {
this.preview = preview
return this
}
public fun gradient(gradient: Gradient?): Builder {
this.gradient = gradient
this.color = null
return this
}
public fun color(color: Int?): Builder {
this.color = color
this.gradient = null
return this
}
public override fun build(): TextAttachment = TextAttachment(
text = text,
textStyle = textStyle,
textForegroundColor = textForegroundColor,
textBackgroundColor = textBackgroundColor,
preview = preview,
gradient = gradient,
color = color,
unknownFields = buildUnknownFields()
)
}
public companion object {
@JvmField
public val ADAPTER: ProtoAdapter = object : ProtoAdapter(
FieldEncoding.LENGTH_DELIMITED,
TextAttachment::class,
"type.googleapis.com/signalservice.TextAttachment",
PROTO_2,
null,
"SignalService.proto"
) {
public override fun encodedSize(`value`: TextAttachment): Int {
var size = value.unknownFields.size
size += ProtoAdapter.STRING.encodedSizeWithTag(1, value.text)
size += Style.ADAPTER.encodedSizeWithTag(2, value.textStyle)
size += ProtoAdapter.UINT32.encodedSizeWithTag(3, value.textForegroundColor)
size += ProtoAdapter.UINT32.encodedSizeWithTag(4, value.textBackgroundColor)
size += Preview.ADAPTER.encodedSizeWithTag(5, value.preview)
size += Gradient.ADAPTER.encodedSizeWithTag(6, value.gradient)
size += ProtoAdapter.UINT32.encodedSizeWithTag(7, value.color)
return size
}
public override fun encode(writer: ProtoWriter, `value`: TextAttachment): Unit {
ProtoAdapter.STRING.encodeWithTag(writer, 1, value.text)
Style.ADAPTER.encodeWithTag(writer, 2, value.textStyle)
ProtoAdapter.UINT32.encodeWithTag(writer, 3, value.textForegroundColor)
ProtoAdapter.UINT32.encodeWithTag(writer, 4, value.textBackgroundColor)
Preview.ADAPTER.encodeWithTag(writer, 5, value.preview)
Gradient.ADAPTER.encodeWithTag(writer, 6, value.gradient)
ProtoAdapter.UINT32.encodeWithTag(writer, 7, value.color)
writer.writeBytes(value.unknownFields)
}
public override fun encode(writer: ReverseProtoWriter, `value`: TextAttachment): Unit {
writer.writeBytes(value.unknownFields)
ProtoAdapter.UINT32.encodeWithTag(writer, 7, value.color)
Gradient.ADAPTER.encodeWithTag(writer, 6, value.gradient)
Preview.ADAPTER.encodeWithTag(writer, 5, value.preview)
ProtoAdapter.UINT32.encodeWithTag(writer, 4, value.textBackgroundColor)
ProtoAdapter.UINT32.encodeWithTag(writer, 3, value.textForegroundColor)
Style.ADAPTER.encodeWithTag(writer, 2, value.textStyle)
ProtoAdapter.STRING.encodeWithTag(writer, 1, value.text)
}
public override fun decode(reader: ProtoReader): TextAttachment {
var text: String? = null
var textStyle: Style? = null
var textForegroundColor: Int? = null
var textBackgroundColor: Int? = null
var preview: Preview? = null
var gradient: Gradient? = null
var color: Int? = null
val unknownFields = reader.forEachTag { tag ->
when (tag) {
1 -> text = ProtoAdapter.STRING.decode(reader)
2 -> try {
textStyle = Style.ADAPTER.decode(reader)
} catch (e: ProtoAdapter.EnumConstantNotFoundException) {
reader.addUnknownField(tag, FieldEncoding.VARINT, e.value.toLong())
}
3 -> textForegroundColor = ProtoAdapter.UINT32.decode(reader)
4 -> textBackgroundColor = ProtoAdapter.UINT32.decode(reader)
5 -> preview = Preview.ADAPTER.decode(reader)
6 -> gradient = Gradient.ADAPTER.decode(reader)
7 -> color = ProtoAdapter.UINT32.decode(reader)
else -> reader.readUnknownField(tag)
}
}
return TextAttachment(
text = text,
textStyle = textStyle,
textForegroundColor = textForegroundColor,
textBackgroundColor = textBackgroundColor,
preview = preview,
gradient = gradient,
color = color,
unknownFields = unknownFields
)
}
public override fun redact(`value`: TextAttachment): TextAttachment = value.copy(
preview = value.preview?.let(Preview.ADAPTER::redact),
gradient = value.gradient?.let(Gradient.ADAPTER::redact),
unknownFields = ByteString.EMPTY
)
}
private const val serialVersionUID: Long = 0L
}
public enum class Style(
public override val `value`: Int,
) : WireEnum {
DEFAULT(0),
REGULAR(1),
BOLD(2),
SERIF(3),
SCRIPT(4),
CONDENSED(5),
;
public companion object {
@JvmField
public val ADAPTER: ProtoAdapter