forked from square/wire
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dinosaur.kt
195 lines (182 loc) · 7.2 KB
/
Dinosaur.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
// Code generated by Wire protocol buffer compiler, do not edit.
// Source: squareup.dinosaurs.Dinosaur in squareup/dinosaurs/dinosaur.proto
package com.squareup.dinosaurs
import com.squareup.geology.Period
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.PROTO_2
import com.squareup.wire.WireField
import com.squareup.wire.`internal`.immutableCopyOf
import com.squareup.wire.`internal`.sanitize
import kotlin.Any
import kotlin.AssertionError
import kotlin.Boolean
import kotlin.Deprecated
import kotlin.DeprecationLevel
import kotlin.Double
import kotlin.Int
import kotlin.Long
import kotlin.Nothing
import kotlin.String
import kotlin.Unit
import kotlin.collections.List
import kotlin.jvm.JvmField
import okio.ByteString
public class Dinosaur(
/**
* Common name of this dinosaur, like "Stegosaurus".
*/
@field:WireField(
tag = 1,
adapter = "com.squareup.wire.ProtoAdapter#STRING",
)
public val name: String? = null,
picture_urls: List<String> = emptyList(),
@field:WireField(
tag = 3,
adapter = "com.squareup.wire.ProtoAdapter#DOUBLE",
)
public val length_meters: Double? = null,
@field:WireField(
tag = 4,
adapter = "com.squareup.wire.ProtoAdapter#DOUBLE",
)
public val mass_kilograms: Double? = null,
@field:WireField(
tag = 5,
adapter = "com.squareup.geology.Period#ADAPTER",
)
public val period: Period? = null,
unknownFields: ByteString = ByteString.EMPTY,
) : Message<Dinosaur, Nothing>(ADAPTER, unknownFields) {
/**
* URLs with images of this dinosaur.
*/
@field:WireField(
tag = 2,
adapter = "com.squareup.wire.ProtoAdapter#STRING",
label = WireField.Label.REPEATED,
)
public val picture_urls: List<String> = immutableCopyOf("picture_urls", picture_urls)
@Deprecated(
message = "Shouldn't be used in Kotlin",
level = DeprecationLevel.HIDDEN,
)
public override fun newBuilder(): Nothing = throw
AssertionError("Builders are deprecated and only available in a javaInterop build; see https://square.github.io/wire/wire_compiler/#kotlin")
public override fun equals(other: Any?): Boolean {
if (other === this) return true
if (other !is Dinosaur) return false
if (unknownFields != other.unknownFields) return false
if (name != other.name) return false
if (picture_urls != other.picture_urls) return false
if (length_meters != other.length_meters) return false
if (mass_kilograms != other.mass_kilograms) return false
if (period != other.period) return false
return true
}
public override fun hashCode(): Int {
var result = super.hashCode
if (result == 0) {
result = unknownFields.hashCode()
result = result * 37 + (name?.hashCode() ?: 0)
result = result * 37 + picture_urls.hashCode()
result = result * 37 + (length_meters?.hashCode() ?: 0)
result = result * 37 + (mass_kilograms?.hashCode() ?: 0)
result = result * 37 + (period?.hashCode() ?: 0)
super.hashCode = result
}
return result
}
public override fun toString(): String {
val result = mutableListOf<String>()
if (name != null) result += """name=${sanitize(name)}"""
if (picture_urls.isNotEmpty()) result += """picture_urls=${sanitize(picture_urls)}"""
if (length_meters != null) result += """length_meters=$length_meters"""
if (mass_kilograms != null) result += """mass_kilograms=$mass_kilograms"""
if (period != null) result += """period=$period"""
return result.joinToString(prefix = "Dinosaur{", separator = ", ", postfix = "}")
}
public fun copy(
name: String? = this.name,
picture_urls: List<String> = this.picture_urls,
length_meters: Double? = this.length_meters,
mass_kilograms: Double? = this.mass_kilograms,
period: Period? = this.period,
unknownFields: ByteString = this.unknownFields,
): Dinosaur = Dinosaur(name, picture_urls, length_meters, mass_kilograms, period, unknownFields)
public companion object {
@JvmField
public val ADAPTER: ProtoAdapter<Dinosaur> = object : ProtoAdapter<Dinosaur>(
FieldEncoding.LENGTH_DELIMITED,
Dinosaur::class,
"type.googleapis.com/squareup.dinosaurs.Dinosaur",
PROTO_2,
null,
"squareup/dinosaurs/dinosaur.proto"
) {
public override fun encodedSize(`value`: Dinosaur): Int {
var size = value.unknownFields.size
size += ProtoAdapter.STRING.encodedSizeWithTag(1, value.name)
size += ProtoAdapter.STRING.asRepeated().encodedSizeWithTag(2, value.picture_urls)
size += ProtoAdapter.DOUBLE.encodedSizeWithTag(3, value.length_meters)
size += ProtoAdapter.DOUBLE.encodedSizeWithTag(4, value.mass_kilograms)
size += Period.ADAPTER.encodedSizeWithTag(5, value.period)
return size
}
public override fun encode(writer: ProtoWriter, `value`: Dinosaur): Unit {
ProtoAdapter.STRING.encodeWithTag(writer, 1, value.name)
ProtoAdapter.STRING.asRepeated().encodeWithTag(writer, 2, value.picture_urls)
ProtoAdapter.DOUBLE.encodeWithTag(writer, 3, value.length_meters)
ProtoAdapter.DOUBLE.encodeWithTag(writer, 4, value.mass_kilograms)
Period.ADAPTER.encodeWithTag(writer, 5, value.period)
writer.writeBytes(value.unknownFields)
}
public override fun encode(writer: ReverseProtoWriter, `value`: Dinosaur): Unit {
writer.writeBytes(value.unknownFields)
Period.ADAPTER.encodeWithTag(writer, 5, value.period)
ProtoAdapter.DOUBLE.encodeWithTag(writer, 4, value.mass_kilograms)
ProtoAdapter.DOUBLE.encodeWithTag(writer, 3, value.length_meters)
ProtoAdapter.STRING.asRepeated().encodeWithTag(writer, 2, value.picture_urls)
ProtoAdapter.STRING.encodeWithTag(writer, 1, value.name)
}
public override fun decode(reader: ProtoReader): Dinosaur {
var name: String? = null
val picture_urls = mutableListOf<String>()
var length_meters: Double? = null
var mass_kilograms: Double? = null
var period: Period? = null
val unknownFields = reader.forEachTag { tag ->
when (tag) {
1 -> name = ProtoAdapter.STRING.decode(reader)
2 -> picture_urls.add(ProtoAdapter.STRING.decode(reader))
3 -> length_meters = ProtoAdapter.DOUBLE.decode(reader)
4 -> mass_kilograms = ProtoAdapter.DOUBLE.decode(reader)
5 -> try {
period = Period.ADAPTER.decode(reader)
} catch (e: ProtoAdapter.EnumConstantNotFoundException) {
reader.addUnknownField(tag, FieldEncoding.VARINT, e.value.toLong())
}
else -> reader.readUnknownField(tag)
}
}
return Dinosaur(
name = name,
picture_urls = picture_urls,
length_meters = length_meters,
mass_kilograms = mass_kilograms,
period = period,
unknownFields = unknownFields
)
}
public override fun redact(`value`: Dinosaur): Dinosaur = value.copy(
unknownFields = ByteString.EMPTY
)
}
private const val serialVersionUID: Long = 0L
}
}