private static final void setProtobufFieldValue ( ProtobufAttribute protobufAttribute , Builder protoObjBuilder , String setter , Object fieldValue ) throws NoSuchMethodException , SecurityException , ProtobufAnnotationException , InstantiationException , IllegalAccessException , IllegalArgumentException , InvocationTargetException { Class < ? extends Object > fieldValueClass = fieldValue . getClass ( ) ; Class < ? extends Object > gpbClass = fieldValueClass ; final Class < ? extends IProtobufConverter > converterClazz = protobufAttribute . converter ( ) ; if ( converterClazz != NullConverter . class ) { final IProtobufConverter protoBufConverter = ( IProtobufConverter ) converterClazz . newInstance ( ) ; fieldValue = protoBufConverter . convertToProtobuf ( fieldValue ) ; gpbClass = fieldValue . getClass ( ) ; fieldValueClass = gpbClass ; } // Need to convert the argument class from non-primitives to primitives, as Protobuf uses these. gpbClass = ProtobufSerializerUtils . getProtobufClass ( fieldValue , gpbClass ) ; final Method gpbMethod = protoObjBuilder . getClass ( ) . getDeclaredMethod ( setter , gpbClass ) ; gpbMethod . invoke ( protoObjBuilder , fieldValue ) ; }
This method does the actual set on the Protobuf builder . If the user specified a converter then use that right before we actually try and set the value .