You can get all the fields of a protobuf object using getAllFields()
<https://developers.google.com/protocol-buffers/docs/reference/java/com/google/protobuf/MessageOrBuilder.html#getAllFields-->
(for
the source object) and then use setField()
<https://developers.google.com/protocol-buffers/docs/reference/java/com/google/protobuf/Message.Builder.html#setField-com.google.protobuf.Descriptors.FieldDescriptor-java.lang.Object->
on each field on the destination object builder.

On Sun, Jul 5, 2020 at 11:19 PM <[email protected]> wrote:

> But when you say "convert one builder object ... to another builder
> object" do you mean a different type? That ordinarily is not possible.
>
> Yes Different Type. Now we are reading each property from source and
> setting it in destination and building destination Object.
>
> On Monday, 6 July 2020 07:57:58 UTC+5:30, [email protected] wrote:
>>
>> Copy constructor implies copying object to the same type. You can use
>> toBuilder()
>> <https://developers.google.com/protocol-buffers/docs/reference/java/com/google/protobuf/MessageLite.html#toBuilder-->
>>  on
>> the first object to get a builder that enables you to build the second
>> object with the same values.
>>
>> But when you say "convert one builder object ... to another builder
>> object" do you mean a different type? That ordinarily is not possible.
>>
>> On Saturday, July 4, 2020 at 5:11:02 AM UTC-7 [email protected] wrote:
>>
>>>
>>> Recently started using gRPC -Protobuf so the question might be asked
>>> earlier as well. Sorry if im repeating it here.
>>>
>>> I have to convert one protobuf object to another protobuf object in Java.
>>>
>>> Basically response construction. In normal Java world, we can have copy
>>> constructor or BeanUtils copy properties to copy the nested set of objects
>>> to destination. Similar to that Do i have any way to convert one builder
>>> object of a protobuf to another builder object generated from protobuf file.
>>>
>> --
> You received this message because you are subscribed to a topic in the
> Google Groups "grpc.io" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/grpc-io/ESjCIz_2grc/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/grpc-io/c04abc12-90e7-4732-b15e-a43a5f87a663o%40googlegroups.com
> <https://groups.google.com/d/msgid/grpc-io/c04abc12-90e7-4732-b15e-a43a5f87a663o%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/CA%2BPad6gq4pgzvEX%3DQ5kT7vWWriRugbyOOisVoAZNbZKn_wFzsQ%40mail.gmail.com.

Reply via email to