how to automatically copy values from java bean to protobuf message object using java reflection?

Typically I could copy values between two java beans , which have identical property names, using beanutils with java reflection e.g. PropertyUtils.setProperty(....)

In protobuf Message, we use the message builder class to set the value. This works but I would rather use reflection to automatically copy properties from the bean to the message as both have identical property names and type.

When I invoke the PropertyUtils.setProperty on the builder object ( got from message.newBuilder() ) , I get this message.

java.lang.NoSuchMethodException: Property 'testProp' has no setter method in class 'class teststuff.TestBeanProtos$TestBeanMessage$Builder'

How do I automatically copy values from java bean to protobuf message object ( and vice-versa) using java reflection ?

5
задан user193116 29 October 2010 в 16:05
поделиться