16
16
*/
17
17
package org .apache .dubbo .metadata .definition .protobuf ;
18
18
19
+ import org .apache .dubbo .common .extension .Activate ;
19
20
import org .apache .dubbo .common .lang .Prioritized ;
20
21
import org .apache .dubbo .common .logger .Logger ;
21
22
import org .apache .dubbo .common .logger .LoggerFactory ;
37
38
import java .util .regex .Matcher ;
38
39
import java .util .regex .Pattern ;
39
40
41
+ @ Activate (onClass = "com.google.protobuf.GeneratedMessageV3" )
40
42
public class ProtobufTypeBuilder implements TypeBuilder , Prioritized {
41
43
private final Logger logger = LoggerFactory .getLogger (getClass ());
42
44
private static final Pattern MAP_PATTERN = Pattern .compile ("^java\\ .util\\ .Map<(\\ S+), (\\ S+)>$" );
@@ -258,11 +260,7 @@ private boolean isSimplePropertySettingMethod(Method method) {
258
260
// Enum property has two setting method.
259
261
// skip setXXXValue(int value)
260
262
// parse setXXX(SomeEnum value)
261
- if (methodName .endsWith ("Value" ) && types [0 ] == int .class ) {
262
- return false ;
263
- }
264
-
265
- return true ;
263
+ return !methodName .endsWith ("Value" ) || types [0 ] != int .class ;
266
264
}
267
265
268
266
@@ -289,11 +287,7 @@ boolean isListPropertyGettingMethod(Method method) {
289
287
}
290
288
291
289
// if field name end with List, should skip
292
- if (!List .class .isAssignableFrom (type )) {
293
- return false ;
294
- }
295
-
296
- return true ;
290
+ return List .class .isAssignableFrom (type );
297
291
}
298
292
299
293
/**
@@ -307,10 +301,6 @@ boolean isListPropertyGettingMethod(Method method) {
307
301
private boolean isMapPropertySettingMethod (Method methodTemp ) {
308
302
String methodName = methodTemp .getName ();
309
303
Class [] parameters = methodTemp .getParameterTypes ();
310
- if (methodName .startsWith ("putAll" ) && parameters .length == 1 && Map .class .isAssignableFrom (parameters [0 ])) {
311
- return true ;
312
- }
313
-
314
- return false ;
304
+ return methodName .startsWith ("putAll" ) && parameters .length == 1 && Map .class .isAssignableFrom (parameters [0 ]);
315
305
}
316
306
}
0 commit comments