-
Notifications
You must be signed in to change notification settings - Fork 575
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add mutableTypes to Wire plugin and set golden file
- Loading branch information
Showing
11 changed files
with
378 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
wire-golden-files/src/main/kotlin/squareup/wire/mutable/MutableHeader.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
// Code generated by Wire protocol buffer compiler, do not edit. | ||
// Source: squareup.wire.mutable.Header in squareup/wire/mutable_types.proto | ||
@file:Suppress( | ||
"DEPRECATION", | ||
"RUNTIME_ANNOTATION_NOT_SUPPORTED", | ||
) | ||
|
||
package squareup.wire.mutable | ||
|
||
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`.JvmField | ||
import kotlin.Any | ||
import kotlin.Boolean | ||
import kotlin.Int | ||
import kotlin.Long | ||
import kotlin.Nothing | ||
import kotlin.String | ||
import kotlin.Suppress | ||
import kotlin.UnsupportedOperationException | ||
import okio.ByteString | ||
|
||
public class MutableHeader( | ||
@field:WireField( | ||
tag = 1, | ||
adapter = "com.squareup.wire.ProtoAdapter#UINT64", | ||
schemaIndex = 0, | ||
) | ||
public var id: Long? = null, | ||
unknownFields: ByteString = ByteString.EMPTY, | ||
) : Message<MutableHeader, Nothing>(ADAPTER, unknownFields) { | ||
override fun equals(other: Any?): Boolean { | ||
if (other !is MutableHeader) return false | ||
if (unknownFields != other.unknownFields) return false | ||
if (id != other.id) return false | ||
return true | ||
} | ||
|
||
override fun hashCode(): Int { | ||
var result = 0 | ||
result = unknownFields.hashCode() | ||
result = result * 37 + (id?.hashCode() ?: 0) | ||
return result | ||
} | ||
|
||
override fun toString(): String { | ||
val result = mutableListOf<String>() | ||
if (id != null) result += """id=$id""" | ||
return result.joinToString(prefix = "MutableHeader{", separator = ", ", postfix = "}") | ||
} | ||
|
||
public companion object { | ||
@JvmField | ||
public val ADAPTER: ProtoAdapter<MutableHeader> = object : ProtoAdapter<MutableHeader>( | ||
FieldEncoding.LENGTH_DELIMITED, | ||
MutableHeader::class, | ||
"type.googleapis.com/squareup.wire.mutable.Header", | ||
PROTO_2, | ||
null, | ||
"squareup/wire/mutable_types.proto" | ||
) { | ||
override fun encodedSize(`value`: MutableHeader): Int { | ||
var size = value.unknownFields.size | ||
size += ProtoAdapter.UINT64.encodedSizeWithTag(1, value.id) | ||
return size | ||
} | ||
|
||
override fun encode(writer: ProtoWriter, `value`: MutableHeader) { | ||
ProtoAdapter.UINT64.encodeWithTag(writer, 1, value.id) | ||
writer.writeBytes(value.unknownFields) | ||
} | ||
|
||
override fun encode(writer: ReverseProtoWriter, `value`: MutableHeader) { | ||
writer.writeBytes(value.unknownFields) | ||
ProtoAdapter.UINT64.encodeWithTag(writer, 1, value.id) | ||
} | ||
|
||
override fun decode(reader: ProtoReader): MutableHeader { | ||
var id: Long? = null | ||
val unknownFields = reader.forEachTag { tag -> | ||
when (tag) { | ||
1 -> id = ProtoAdapter.UINT64.decode(reader) | ||
else -> reader.readUnknownField(tag) | ||
} | ||
} | ||
return MutableHeader( | ||
id = id, | ||
unknownFields = unknownFields | ||
) | ||
} | ||
|
||
override fun redact(`value`: MutableHeader): MutableHeader = throw UnsupportedOperationException("redact() is unsupported for Mutable message types") | ||
} | ||
|
||
private const val serialVersionUID: Long = 0L | ||
} | ||
} |
119 changes: 119 additions & 0 deletions
119
wire-golden-files/src/main/kotlin/squareup/wire/mutable/MutablePacket.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
// Code generated by Wire protocol buffer compiler, do not edit. | ||
// Source: squareup.wire.mutable.Packet in squareup/wire/mutable_types.proto | ||
@file:Suppress( | ||
"DEPRECATION", | ||
"RUNTIME_ANNOTATION_NOT_SUPPORTED", | ||
) | ||
|
||
package squareup.wire.mutable | ||
|
||
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`.JvmField | ||
import kotlin.Any | ||
import kotlin.Boolean | ||
import kotlin.Int | ||
import kotlin.Long | ||
import kotlin.Nothing | ||
import kotlin.String | ||
import kotlin.Suppress | ||
import kotlin.UnsupportedOperationException | ||
import okio.ByteString | ||
|
||
public class MutablePacket( | ||
@field:WireField( | ||
tag = 1, | ||
adapter = "squareup.wire.mutable.MutableHeader#ADAPTER", | ||
declaredName = "header", | ||
schemaIndex = 0, | ||
) | ||
public var header_: MutableHeader? = null, | ||
@field:WireField( | ||
tag = 2, | ||
adapter = "squareup.wire.mutable.MutablePayload#ADAPTER", | ||
schemaIndex = 1, | ||
) | ||
public var payload: MutablePayload? = null, | ||
unknownFields: ByteString = ByteString.EMPTY, | ||
) : Message<MutablePacket, Nothing>(ADAPTER, unknownFields) { | ||
override fun equals(other: Any?): Boolean { | ||
if (other !is MutablePacket) return false | ||
if (unknownFields != other.unknownFields) return false | ||
if (header_ != other.header_) return false | ||
if (payload != other.payload) return false | ||
return true | ||
} | ||
|
||
override fun hashCode(): Int { | ||
var result = 0 | ||
result = unknownFields.hashCode() | ||
result = result * 37 + (header_?.hashCode() ?: 0) | ||
result = result * 37 + (payload?.hashCode() ?: 0) | ||
return result | ||
} | ||
|
||
override fun toString(): String { | ||
val result = mutableListOf<String>() | ||
if (header_ != null) result += """header_=$header_""" | ||
if (payload != null) result += """payload=$payload""" | ||
return result.joinToString(prefix = "MutablePacket{", separator = ", ", postfix = "}") | ||
} | ||
|
||
public companion object { | ||
@JvmField | ||
public val ADAPTER: ProtoAdapter<MutablePacket> = object : ProtoAdapter<MutablePacket>( | ||
FieldEncoding.LENGTH_DELIMITED, | ||
MutablePacket::class, | ||
"type.googleapis.com/squareup.wire.mutable.Packet", | ||
PROTO_2, | ||
null, | ||
"squareup/wire/mutable_types.proto" | ||
) { | ||
override fun encodedSize(`value`: MutablePacket): Int { | ||
var size = value.unknownFields.size | ||
size += MutableHeader.ADAPTER.encodedSizeWithTag(1, value.header_) | ||
size += MutablePayload.ADAPTER.encodedSizeWithTag(2, value.payload) | ||
return size | ||
} | ||
|
||
override fun encode(writer: ProtoWriter, `value`: MutablePacket) { | ||
MutableHeader.ADAPTER.encodeWithTag(writer, 1, value.header_) | ||
MutablePayload.ADAPTER.encodeWithTag(writer, 2, value.payload) | ||
writer.writeBytes(value.unknownFields) | ||
} | ||
|
||
override fun encode(writer: ReverseProtoWriter, `value`: MutablePacket) { | ||
writer.writeBytes(value.unknownFields) | ||
MutablePayload.ADAPTER.encodeWithTag(writer, 2, value.payload) | ||
MutableHeader.ADAPTER.encodeWithTag(writer, 1, value.header_) | ||
} | ||
|
||
override fun decode(reader: ProtoReader): MutablePacket { | ||
var header_: MutableHeader? = null | ||
var payload: MutablePayload? = null | ||
val unknownFields = reader.forEachTag { tag -> | ||
when (tag) { | ||
1 -> header_ = MutableHeader.ADAPTER.decode(reader) | ||
2 -> payload = MutablePayload.ADAPTER.decode(reader) | ||
else -> reader.readUnknownField(tag) | ||
} | ||
} | ||
return MutablePacket( | ||
header_ = header_, | ||
payload = payload, | ||
unknownFields = unknownFields | ||
) | ||
} | ||
|
||
override fun redact(`value`: MutablePacket): MutablePacket = throw UnsupportedOperationException("redact() is unsupported for Mutable message types") | ||
} | ||
|
||
private const val serialVersionUID: Long = 0L | ||
} | ||
} |
103 changes: 103 additions & 0 deletions
103
wire-golden-files/src/main/kotlin/squareup/wire/mutable/MutablePayload.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
// Code generated by Wire protocol buffer compiler, do not edit. | ||
// Source: squareup.wire.mutable.Payload in squareup/wire/mutable_types.proto | ||
@file:Suppress( | ||
"DEPRECATION", | ||
"RUNTIME_ANNOTATION_NOT_SUPPORTED", | ||
) | ||
|
||
package squareup.wire.mutable | ||
|
||
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`.JvmField | ||
import kotlin.Any | ||
import kotlin.Boolean | ||
import kotlin.Int | ||
import kotlin.Long | ||
import kotlin.Nothing | ||
import kotlin.String | ||
import kotlin.Suppress | ||
import kotlin.UnsupportedOperationException | ||
import okio.ByteString | ||
|
||
public class MutablePayload( | ||
@field:WireField( | ||
tag = 1, | ||
adapter = "com.squareup.wire.ProtoAdapter#BYTES", | ||
schemaIndex = 0, | ||
) | ||
public var content: ByteString? = null, | ||
unknownFields: ByteString = ByteString.EMPTY, | ||
) : Message<MutablePayload, Nothing>(ADAPTER, unknownFields) { | ||
override fun equals(other: Any?): Boolean { | ||
if (other !is MutablePayload) return false | ||
if (unknownFields != other.unknownFields) return false | ||
if (content != other.content) return false | ||
return true | ||
} | ||
|
||
override fun hashCode(): Int { | ||
var result = 0 | ||
result = unknownFields.hashCode() | ||
result = result * 37 + (content?.hashCode() ?: 0) | ||
return result | ||
} | ||
|
||
override fun toString(): String { | ||
val result = mutableListOf<String>() | ||
if (content != null) result += """content=$content""" | ||
return result.joinToString(prefix = "MutablePayload{", separator = ", ", postfix = "}") | ||
} | ||
|
||
public companion object { | ||
@JvmField | ||
public val ADAPTER: ProtoAdapter<MutablePayload> = object : ProtoAdapter<MutablePayload>( | ||
FieldEncoding.LENGTH_DELIMITED, | ||
MutablePayload::class, | ||
"type.googleapis.com/squareup.wire.mutable.Payload", | ||
PROTO_2, | ||
null, | ||
"squareup/wire/mutable_types.proto" | ||
) { | ||
override fun encodedSize(`value`: MutablePayload): Int { | ||
var size = value.unknownFields.size | ||
size += ProtoAdapter.BYTES.encodedSizeWithTag(1, value.content) | ||
return size | ||
} | ||
|
||
override fun encode(writer: ProtoWriter, `value`: MutablePayload) { | ||
ProtoAdapter.BYTES.encodeWithTag(writer, 1, value.content) | ||
writer.writeBytes(value.unknownFields) | ||
} | ||
|
||
override fun encode(writer: ReverseProtoWriter, `value`: MutablePayload) { | ||
writer.writeBytes(value.unknownFields) | ||
ProtoAdapter.BYTES.encodeWithTag(writer, 1, value.content) | ||
} | ||
|
||
override fun decode(reader: ProtoReader): MutablePayload { | ||
var content: ByteString? = null | ||
val unknownFields = reader.forEachTag { tag -> | ||
when (tag) { | ||
1 -> content = ProtoAdapter.BYTES.decode(reader) | ||
else -> reader.readUnknownField(tag) | ||
} | ||
} | ||
return MutablePayload( | ||
content = content, | ||
unknownFields = unknownFields | ||
) | ||
} | ||
|
||
override fun redact(`value`: MutablePayload): MutablePayload = throw UnsupportedOperationException("redact() is unsupported for Mutable message types") | ||
} | ||
|
||
private const val serialVersionUID: Long = 0L | ||
} | ||
} |
2 changes: 0 additions & 2 deletions
2
wire-golden-files/src/main/proto/squareup/wire/hundreds_redacted.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
wire-golden-files/src/main/proto/squareup/wire/mutable_types.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
syntax = "proto2"; | ||
|
||
package squareup.wire.mutable; | ||
|
||
message Header { | ||
optional uint64 id = 1; | ||
} | ||
|
||
message Payload { | ||
optional bytes content = 1; | ||
} | ||
|
||
message Packet { | ||
optional Header header = 1; | ||
optional Payload payload = 2; | ||
} |
Oops, something went wrong.