这是示例代码片
public OperationResult beforeEverything(BDDObject savingObject) {
String checkAssetRole = doCheckAssetRole(savingObject);
if (checkAssetRole != null && !checkAssetRole.equals("MissingAssetRole")) {
return new OperationResult(new OperationExecutionError("SIP-37006",
new String[] {"Duplicate asset roles have been defined: " + checkAssetRole},
getLocalizationGate()));
}
ArrayList<String> warnings = new ArrayList<String>();
boolean showWarning = false;
if (checkAssetRole != null && checkAssetRole.equals("MissingAssetRole")) {
mLogger.debug("Warning of Asset role");
warnings.add(new String(
"Asset role is missing. Do you want to save the record?"));
showWarning = true;
}
return OperationResult.OK;
}
问题是doCheckAssetRole
方法返回null
。那么我该如何在beforeEverything()
方法中处理它。是否需要进行一些异常处理?如果是这样,如何?