Skip to content

Commit 8f84391

Browse files
authored
PB: Added hasCode, equals and toString support (#490)
1 parent be5d2a3 commit 8f84391

File tree

31 files changed

+12201
-241
lines changed

31 files changed

+12201
-241
lines changed

protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/Struct.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public sealed class NullValue(public open val number: Int) {
114114
/**
115115
* Null value.
116116
*/
117-
public object NULL_VALUE: NullValue(number = 0)
117+
public data object NULL_VALUE: NullValue(number = 0)
118118

119119
public data class UNRECOGNIZED(override val number: Int): NullValue(number)
120120

protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/Type.kt

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -95,97 +95,97 @@ public interface Field {
9595
/**
9696
* Field type unknown.
9797
*/
98-
public object TYPE_UNKNOWN: Kind(number = 0)
98+
public data object TYPE_UNKNOWN: Kind(number = 0)
9999

100100
/**
101101
* Field type double.
102102
*/
103-
public object TYPE_DOUBLE: Kind(number = 1)
103+
public data object TYPE_DOUBLE: Kind(number = 1)
104104

105105
/**
106106
* Field type float.
107107
*/
108-
public object TYPE_FLOAT: Kind(number = 2)
108+
public data object TYPE_FLOAT: Kind(number = 2)
109109

110110
/**
111111
* Field type int64.
112112
*/
113-
public object TYPE_INT64: Kind(number = 3)
113+
public data object TYPE_INT64: Kind(number = 3)
114114

115115
/**
116116
* Field type uint64.
117117
*/
118-
public object TYPE_UINT64: Kind(number = 4)
118+
public data object TYPE_UINT64: Kind(number = 4)
119119

120120
/**
121121
* Field type int32.
122122
*/
123-
public object TYPE_INT32: Kind(number = 5)
123+
public data object TYPE_INT32: Kind(number = 5)
124124

125125
/**
126126
* Field type fixed64.
127127
*/
128-
public object TYPE_FIXED64: Kind(number = 6)
128+
public data object TYPE_FIXED64: Kind(number = 6)
129129

130130
/**
131131
* Field type fixed32.
132132
*/
133-
public object TYPE_FIXED32: Kind(number = 7)
133+
public data object TYPE_FIXED32: Kind(number = 7)
134134

135135
/**
136136
* Field type bool.
137137
*/
138-
public object TYPE_BOOL: Kind(number = 8)
138+
public data object TYPE_BOOL: Kind(number = 8)
139139

140140
/**
141141
* Field type string.
142142
*/
143-
public object TYPE_STRING: Kind(number = 9)
143+
public data object TYPE_STRING: Kind(number = 9)
144144

145145
/**
146146
* Field type group. Proto2 syntax only, and deprecated.
147147
*/
148-
public object TYPE_GROUP: Kind(number = 10)
148+
public data object TYPE_GROUP: Kind(number = 10)
149149

150150
/**
151151
* Field type message.
152152
*/
153-
public object TYPE_MESSAGE: Kind(number = 11)
153+
public data object TYPE_MESSAGE: Kind(number = 11)
154154

155155
/**
156156
* Field type bytes.
157157
*/
158-
public object TYPE_BYTES: Kind(number = 12)
158+
public data object TYPE_BYTES: Kind(number = 12)
159159

160160
/**
161161
* Field type uint32.
162162
*/
163-
public object TYPE_UINT32: Kind(number = 13)
163+
public data object TYPE_UINT32: Kind(number = 13)
164164

165165
/**
166166
* Field type enum.
167167
*/
168-
public object TYPE_ENUM: Kind(number = 14)
168+
public data object TYPE_ENUM: Kind(number = 14)
169169

170170
/**
171171
* Field type sfixed32.
172172
*/
173-
public object TYPE_SFIXED32: Kind(number = 15)
173+
public data object TYPE_SFIXED32: Kind(number = 15)
174174

175175
/**
176176
* Field type sfixed64.
177177
*/
178-
public object TYPE_SFIXED64: Kind(number = 16)
178+
public data object TYPE_SFIXED64: Kind(number = 16)
179179

180180
/**
181181
* Field type sint32.
182182
*/
183-
public object TYPE_SINT32: Kind(number = 17)
183+
public data object TYPE_SINT32: Kind(number = 17)
184184

185185
/**
186186
* Field type sint64.
187187
*/
188-
public object TYPE_SINT64: Kind(number = 18)
188+
public data object TYPE_SINT64: Kind(number = 18)
189189

190190
public data class UNRECOGNIZED(override val number: Int): Kind(number)
191191

@@ -201,22 +201,22 @@ public interface Field {
201201
/**
202202
* For fields with unknown cardinality.
203203
*/
204-
public object CARDINALITY_UNKNOWN: Cardinality(number = 0)
204+
public data object CARDINALITY_UNKNOWN: Cardinality(number = 0)
205205

206206
/**
207207
* For optional fields.
208208
*/
209-
public object CARDINALITY_OPTIONAL: Cardinality(number = 1)
209+
public data object CARDINALITY_OPTIONAL: Cardinality(number = 1)
210210

211211
/**
212212
* For required fields. Proto2 syntax only.
213213
*/
214-
public object CARDINALITY_REQUIRED: Cardinality(number = 2)
214+
public data object CARDINALITY_REQUIRED: Cardinality(number = 2)
215215

216216
/**
217217
* For repeated fields.
218218
*/
219-
public object CARDINALITY_REPEATED: Cardinality(number = 3)
219+
public data object CARDINALITY_REPEATED: Cardinality(number = 3)
220220

221221
public data class UNRECOGNIZED(override val number: Int): Cardinality(number)
222222

@@ -313,17 +313,17 @@ public sealed class Syntax(public open val number: Int) {
313313
/**
314314
* Syntax `proto2`.
315315
*/
316-
public object SYNTAX_PROTO2: Syntax(number = 0)
316+
public data object SYNTAX_PROTO2: Syntax(number = 0)
317317

318318
/**
319319
* Syntax `proto3`.
320320
*/
321-
public object SYNTAX_PROTO3: Syntax(number = 1)
321+
public data object SYNTAX_PROTO3: Syntax(number = 1)
322322

323323
/**
324324
* Syntax `editions`.
325325
*/
326-
public object SYNTAX_EDITIONS: Syntax(number = 2)
326+
public data object SYNTAX_EDITIONS: Syntax(number = 2)
327327

328328
public data class UNRECOGNIZED(override val number: Int): Syntax(number)
329329

protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Any.kt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,40 @@ public class AnyInternal: com.google.protobuf.kotlin.Any, kotlinx.rpc.protobuf.i
1212
public override var typeUrl: String by MsgFieldDelegate { "" }
1313
public override var value: ByteArray by MsgFieldDelegate { byteArrayOf() }
1414

15+
public override fun hashCode(): kotlin.Int {
16+
checkRequiredFields()
17+
var result = typeUrl.hashCode()
18+
result = 31 * result + value.contentHashCode()
19+
return result
20+
}
21+
22+
public override fun equals(other: kotlin.Any?): kotlin.Boolean {
23+
checkRequiredFields()
24+
if (this === other) return true
25+
if (other == null || this::class != other::class) return false
26+
other as AnyInternal
27+
other.checkRequiredFields()
28+
if (typeUrl != other.typeUrl) return false
29+
if (!value.contentEquals(other.value)) return false
30+
return true
31+
}
32+
33+
public override fun toString(): kotlin.String {
34+
return asString()
35+
}
36+
37+
public fun asString(indent: kotlin.Int = 0): kotlin.String {
38+
checkRequiredFields()
39+
val indentString = " ".repeat(indent)
40+
val nextIndentString = " ".repeat(indent + 4)
41+
return buildString {
42+
appendLine("com.google.protobuf.kotlin.Any(")
43+
appendLine("${nextIndentString}typeUrl=${typeUrl},")
44+
appendLine("${nextIndentString}value=${value.contentToString()},")
45+
append("${indentString})")
46+
}
47+
}
48+
1549
@kotlinx.rpc.internal.utils.InternalRpcApi
1650
public object CODEC: kotlinx.rpc.grpc.codec.MessageCodec<com.google.protobuf.kotlin.Any> {
1751
public override fun encode(value: com.google.protobuf.kotlin.Any): kotlinx.rpc.protobuf.input.stream.InputStream {

protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Api.kt

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,61 @@ public class ApiInternal: com.google.protobuf.kotlin.Api, kotlinx.rpc.protobuf.i
2121
public override var mixins: List<com.google.protobuf.kotlin.Mixin> by MsgFieldDelegate { mutableListOf() }
2222
public override var syntax: com.google.protobuf.kotlin.Syntax by MsgFieldDelegate { com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2 }
2323

24+
public override fun hashCode(): kotlin.Int {
25+
checkRequiredFields()
26+
var result = name.hashCode()
27+
result = 31 * result + methods.hashCode()
28+
result = 31 * result + options.hashCode()
29+
result = 31 * result + version.hashCode()
30+
result = 31 * result + if (presenceMask[0]) sourceContext.hashCode() else 0
31+
result = 31 * result + mixins.hashCode()
32+
result = 31 * result + syntax.hashCode()
33+
return result
34+
}
35+
36+
public override fun equals(other: kotlin.Any?): kotlin.Boolean {
37+
checkRequiredFields()
38+
if (this === other) return true
39+
if (other == null || this::class != other::class) return false
40+
other as ApiInternal
41+
other.checkRequiredFields()
42+
if (presenceMask != other.presenceMask) return false
43+
if (name != other.name) return false
44+
if (methods != other.methods) return false
45+
if (options != other.options) return false
46+
if (version != other.version) return false
47+
if (presenceMask[0] && sourceContext != other.sourceContext) return false
48+
if (mixins != other.mixins) return false
49+
if (syntax != other.syntax) return false
50+
return true
51+
}
52+
53+
public override fun toString(): kotlin.String {
54+
return asString()
55+
}
56+
57+
public fun asString(indent: kotlin.Int = 0): kotlin.String {
58+
checkRequiredFields()
59+
val indentString = " ".repeat(indent)
60+
val nextIndentString = " ".repeat(indent + 4)
61+
return buildString {
62+
appendLine("com.google.protobuf.kotlin.Api(")
63+
appendLine("${nextIndentString}name=${name},")
64+
appendLine("${nextIndentString}methods=${methods},")
65+
appendLine("${nextIndentString}options=${options},")
66+
appendLine("${nextIndentString}version=${version},")
67+
if (presenceMask[0]) {
68+
appendLine("${nextIndentString}sourceContext=${sourceContext.asInternal().asString(indent = indent + 4)},")
69+
} else {
70+
appendLine("${nextIndentString}sourceContext=<unset>,")
71+
}
72+
73+
appendLine("${nextIndentString}mixins=${mixins},")
74+
appendLine("${nextIndentString}syntax=${syntax},")
75+
append("${indentString})")
76+
}
77+
}
78+
2479
@kotlinx.rpc.internal.utils.InternalRpcApi
2580
public object CODEC: kotlinx.rpc.grpc.codec.MessageCodec<com.google.protobuf.kotlin.Api> {
2681
public override fun encode(value: com.google.protobuf.kotlin.Api): kotlinx.rpc.protobuf.input.stream.InputStream {
@@ -61,6 +116,55 @@ public class MethodInternal: com.google.protobuf.kotlin.Method, kotlinx.rpc.prot
61116
public override var options: List<com.google.protobuf.kotlin.Option> by MsgFieldDelegate { mutableListOf() }
62117
public override var syntax: com.google.protobuf.kotlin.Syntax by MsgFieldDelegate { com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2 }
63118

119+
public override fun hashCode(): kotlin.Int {
120+
checkRequiredFields()
121+
var result = name.hashCode()
122+
result = 31 * result + requestTypeUrl.hashCode()
123+
result = 31 * result + requestStreaming.hashCode()
124+
result = 31 * result + responseTypeUrl.hashCode()
125+
result = 31 * result + responseStreaming.hashCode()
126+
result = 31 * result + options.hashCode()
127+
result = 31 * result + syntax.hashCode()
128+
return result
129+
}
130+
131+
public override fun equals(other: kotlin.Any?): kotlin.Boolean {
132+
checkRequiredFields()
133+
if (this === other) return true
134+
if (other == null || this::class != other::class) return false
135+
other as MethodInternal
136+
other.checkRequiredFields()
137+
if (name != other.name) return false
138+
if (requestTypeUrl != other.requestTypeUrl) return false
139+
if (requestStreaming != other.requestStreaming) return false
140+
if (responseTypeUrl != other.responseTypeUrl) return false
141+
if (responseStreaming != other.responseStreaming) return false
142+
if (options != other.options) return false
143+
if (syntax != other.syntax) return false
144+
return true
145+
}
146+
147+
public override fun toString(): kotlin.String {
148+
return asString()
149+
}
150+
151+
public fun asString(indent: kotlin.Int = 0): kotlin.String {
152+
checkRequiredFields()
153+
val indentString = " ".repeat(indent)
154+
val nextIndentString = " ".repeat(indent + 4)
155+
return buildString {
156+
appendLine("com.google.protobuf.kotlin.Method(")
157+
appendLine("${nextIndentString}name=${name},")
158+
appendLine("${nextIndentString}requestTypeUrl=${requestTypeUrl},")
159+
appendLine("${nextIndentString}requestStreaming=${requestStreaming},")
160+
appendLine("${nextIndentString}responseTypeUrl=${responseTypeUrl},")
161+
appendLine("${nextIndentString}responseStreaming=${responseStreaming},")
162+
appendLine("${nextIndentString}options=${options},")
163+
appendLine("${nextIndentString}syntax=${syntax},")
164+
append("${indentString})")
165+
}
166+
}
167+
64168
@kotlinx.rpc.internal.utils.InternalRpcApi
65169
public object CODEC: kotlinx.rpc.grpc.codec.MessageCodec<com.google.protobuf.kotlin.Method> {
66170
public override fun encode(value: com.google.protobuf.kotlin.Method): kotlinx.rpc.protobuf.input.stream.InputStream {
@@ -96,6 +200,40 @@ public class MixinInternal: com.google.protobuf.kotlin.Mixin, kotlinx.rpc.protob
96200
public override var name: String by MsgFieldDelegate { "" }
97201
public override var root: String by MsgFieldDelegate { "" }
98202

203+
public override fun hashCode(): kotlin.Int {
204+
checkRequiredFields()
205+
var result = name.hashCode()
206+
result = 31 * result + root.hashCode()
207+
return result
208+
}
209+
210+
public override fun equals(other: kotlin.Any?): kotlin.Boolean {
211+
checkRequiredFields()
212+
if (this === other) return true
213+
if (other == null || this::class != other::class) return false
214+
other as MixinInternal
215+
other.checkRequiredFields()
216+
if (name != other.name) return false
217+
if (root != other.root) return false
218+
return true
219+
}
220+
221+
public override fun toString(): kotlin.String {
222+
return asString()
223+
}
224+
225+
public fun asString(indent: kotlin.Int = 0): kotlin.String {
226+
checkRequiredFields()
227+
val indentString = " ".repeat(indent)
228+
val nextIndentString = " ".repeat(indent + 4)
229+
return buildString {
230+
appendLine("com.google.protobuf.kotlin.Mixin(")
231+
appendLine("${nextIndentString}name=${name},")
232+
appendLine("${nextIndentString}root=${root},")
233+
append("${indentString})")
234+
}
235+
}
236+
99237
@kotlinx.rpc.internal.utils.InternalRpcApi
100238
public object CODEC: kotlinx.rpc.grpc.codec.MessageCodec<com.google.protobuf.kotlin.Mixin> {
101239
public override fun encode(value: com.google.protobuf.kotlin.Mixin): kotlinx.rpc.protobuf.input.stream.InputStream {

0 commit comments

Comments
 (0)