Method[] methods = bbMsg.getClass().getMethods();
for (Method method : methods) {
String methodName = method.getName();
if (methodName.startsWith("get") && !"getDestinationTemplate".equals(methodName)) {
if (method.getReturnType() == String.class && CollectionUtils.isNotEmpty(getNullValueSet())) {
setDefaultNullString(bbMsg, method, methodName);
}
}
}
private void setDefaultNullString(IPBBRefDataBO bbMsg, Method method, String methodName) {
try {
String getValue = (String) method.invoke(bbMsg);
if (getNullValueSet().contains(getValue)) {
setDefaultNullString(bbMsg, methodName);
}
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
LOGGER.warn("fail to call method " + methodName + ", message:" + bbMsg.toString());
}
}
private void setDefaultNullString(IPBBRefDataBO bbMsg, String methodName) {
String setmethodName = methodName.replace("get", "set");
try {
bbMsg.getClass().getMethod(setmethodName, String.class).invoke(bbMsg, new Object[] { null });
} catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException
| InvocationTargetException e) {
LOGGER.warn("fail to call method " + methodName + ", message:" + bbMsg.toString());
}
}
for (Method method : methods) {
String methodName = method.getName();
if (methodName.startsWith("get") && !"getDestinationTemplate".equals(methodName)) {
if (method.getReturnType() == String.class && CollectionUtils.isNotEmpty(getNullValueSet())) {
setDefaultNullString(bbMsg, method, methodName);
}
}
}
private void setDefaultNullString(IPBBRefDataBO bbMsg, Method method, String methodName) {
try {
String getValue = (String) method.invoke(bbMsg);
if (getNullValueSet().contains(getValue)) {
setDefaultNullString(bbMsg, methodName);
}
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
LOGGER.warn("fail to call method " + methodName + ", message:" + bbMsg.toString());
}
}
private void setDefaultNullString(IPBBRefDataBO bbMsg, String methodName) {
String setmethodName = methodName.replace("get", "set");
try {
bbMsg.getClass().getMethod(setmethodName, String.class).invoke(bbMsg, new Object[] { null });
} catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException
| InvocationTargetException e) {
LOGGER.warn("fail to call method " + methodName + ", message:" + bbMsg.toString());
}
}