*/\r
package org.openo.holmes.rulemgt.db;\r
\r
+import java.beans.PropertyDescriptor;\r
import java.lang.reflect.Field;\r
import java.lang.reflect.Method;\r
import java.util.ArrayList;\r
String whereSql = " WHERE ";\r
\r
for (Field field : fields) {\r
- String methodName = getMethodName(field);\r
-\r
- // If these lines are removed, Jacoco will cause an exception when calculation the coverage of UT\r
- // Remove it if someday Jacoco solve this problem\r
- if (methodName.contains("jacoco")){\r
+ // Jacoco will cause an exception when calculating the coverage of the UT\r
+ // Remove this if jacoco solves this problem in the future\r
+ if (field.getName().contains("jacoco")){\r
continue;\r
}\r
\r
- Method method = clazz.getMethod(methodName);\r
- Object o = method.invoke(ruleQueryCondition);\r
+ PropertyDescriptor pd = new PropertyDescriptor(field.getName(),\r
+ clazz);\r
+ Method getMethod = pd.getReadMethod();\r
+ Object o = getMethod.invoke(ruleQueryCondition);\r
if (o != null) {\r
String tempName = field.getName();\r
if ("enabled".equals(tempName) && (int) o != RuleMgtConstant.STATUS_RULE_ALL) {\r