Slide 105
Slide 105 text
if (occupation != null) result += """occupation=$occupation"""
return result.joinToString(prefix = "Person{", separator = ", ", postfix = "}")
}
@Deprecated(
message = "Shouldn't be used in Kotlin",
level = DeprecationLevel.HIDDEN
)
override fun newBuilder(): Nothing {
throw AssertionError()
}
fun copy(
id: Int = this.id,
name: String? = this.name,
occupation: Occupation? = this.occupation,
unknownFields: ByteString = this.unknownFields
): Person = Person(id, name, occupation, unknownFields)
companion object {
@JvmField
val ADAPTER: ProtoAdapter = object : ProtoAdapter(
FieldEncoding.LENGTH_DELIMITED,
Person::class
) {
override fun encodedSize(value: Person): Int =
ProtoAdapter.INT32.encodedSizeWithTag(1, value.id) +
ProtoAdapter.STRING.encodedSizeWithTag(2, value.name) +
Occupation.ADAPTER.encodedSizeWithTag(3, value.occupation) +