marcoferrer / kroto-plus

gRPC Kotlin Coroutines, Protobuf DSL, Scripting for Protoc
Apache License 2.0
493 stars 28 forks source link

Add extensions copy function to messages #1

Closed ghost closed 6 years ago

ghost commented 6 years ago

After applying this library to our project I found that the only missing builders I have missing are messages that are transformed back to builders to create a copy with a slight modification.

In order to do that I suggest to add a extensions function called copy (the same as data classes) that handles the transformation to builder and the build. It can be written like this:

fun Message.copy(block: Message.Builder.() -> Unit) = this.toBuilder().apply(block).build()

marcoferrer commented 6 years ago

This has been released in v0.1.2