我们有一个带有多个if条件(实际代码有超过100个if条件)的java代码,可以根据操作名调用适当的方法。如何以更有效的方式重构?
if ("Customer".equals(header.getString(OPERATION)))
CustomerRequest searchRequest = gson.fromJson(paylaod, CustomerRequest.class);
response = viewCustomerServiceEndpoint.viewCustomer(searchRequest, pool);
}
if ("ProfileUpdate".equals(header.getString(OPERATION))) {
ProfileUpdateRequest searchRequest = gson.fromJson(paylaod, ProfileUpdateRequest.class);
response = saProfileUpdateEndPoint.saProfileUpdate(searchRequest, pool);
}
暂无答案!
目前还没有任何答案,快来回答吧!