如何在多个if条件下重构Java代码

问题描述

我们有一个带有多个if条件的Java代码(实际代码的if条件大于100)要根据操作名称调用适当的方法。如何以更有效的方式重构它?

  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);
  }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)