Skip to content

Commit

Permalink
Kotlin, non-builder: chunk redact function every 100 fields (#3214)
Browse files Browse the repository at this point in the history
* Kotlin, non-builder: chunk redact function every 100 fields

* avoid impacting other tests

* spotless

* remove debug log

* Golden file + refactoring

---------

Co-authored-by: Benoît Quenaudon <benoit@quenaudon.com>
  • Loading branch information
damianw and oldergod authored Dec 13, 2024
1 parent 90ec9bb commit 65c1bca
Show file tree
Hide file tree
Showing 4 changed files with 5,313 additions and 13 deletions.
87 changes: 87 additions & 0 deletions wire-golden-files/src/main/kotlin/Field.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// Code generated by Wire protocol buffer compiler, do not edit.
// Source: Field in squareup/wire/hundreds_redacted.proto
@file:Suppress(
"DEPRECATION",
"RUNTIME_ANNOTATION_NOT_SUPPORTED",
)

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_3
import com.squareup.wire.`internal`.JvmField
import kotlin.Any
import kotlin.AssertionError
import kotlin.Boolean
import kotlin.Deprecated
import kotlin.DeprecationLevel
import kotlin.Int
import kotlin.Long
import kotlin.Nothing
import kotlin.String
import kotlin.Suppress
import okio.ByteString

public class Field(
unknownFields: ByteString = ByteString.EMPTY,
) : Message<Field, Nothing>(ADAPTER, unknownFields) {
@Deprecated(
message = "Shouldn't be used in Kotlin",
level = DeprecationLevel.HIDDEN,
)
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")

override fun equals(other: Any?): Boolean {
if (other === this) return true
if (other !is Field) return false
if (unknownFields != other.unknownFields) return false
return true
}

override fun hashCode(): Int = unknownFields.hashCode()

override fun toString(): String = "Field{}"

public fun copy(unknownFields: ByteString = this.unknownFields): Field = Field(unknownFields)

public companion object {
@JvmField
public val ADAPTER: ProtoAdapter<Field> = object : ProtoAdapter<Field>(
FieldEncoding.LENGTH_DELIMITED,
Field::class,
"type.googleapis.com/Field",
PROTO_3,
null,
"squareup/wire/hundreds_redacted.proto"
) {
override fun encodedSize(`value`: Field): Int {
var size = value.unknownFields.size
return size
}

override fun encode(writer: ProtoWriter, `value`: Field) {
writer.writeBytes(value.unknownFields)
}

override fun encode(writer: ReverseProtoWriter, `value`: Field) {
writer.writeBytes(value.unknownFields)
}

override fun decode(reader: ProtoReader): Field {
val unknownFields = reader.forEachTag(reader::readUnknownField)
return Field(
unknownFields = unknownFields
)
}

override fun redact(`value`: Field): Field = value.copy(
unknownFields = ByteString.EMPTY
)
}

private const val serialVersionUID: Long = 0L
}
}
Loading

0 comments on commit 65c1bca

Please sign in to comment.