title: How to reduce cyclomatic complexity?
body: <p>I'm working on a class which sends a RequestDTO to a Web Service. I need to validate the request before it is sent.</p>
  
  <p>The request can be sent from 3 different places and there are different validation rules for each "requesttype", e.g. request1 must have name and phonenumber, request2 must have address, etc)</p>
  
  <p>I have a DTO which contains a long list of fields (name, address, city, phonenumber, etc.) and it is the same DTO sent no matter which type of request it is.</p>
  
  <p>I have created 3 different validation methods and based on the type the appropriate method is called.</p>
  
  <p>In each of these methods I have a long list of if-else's to check for the fields that are necessary for each request type.</p>
  
  <pre><code>private void validateRequest1(Request request) {
      StringBuilder sb = new StringBuilder();
      if (null == request) {
          throw new IllegalArgumentException("Request is null");
      }
      if (isFieldEmpty(request.getName())) {  *see below
          sb.append("name,"));
      }
      if (isFieldEmpty(request.getStreet())) {
          sb.append("street,"));
      }
      ...
  </code></pre>
  
  <p><code>isFieldEmpty()</code> checks the string for null and <code>isEmpty()</code> and returns a boolean</p>
  
  <p>This gives me a cyclomatic complexity of 28 in one of those methods so my question is.. is it possible to reduce this complexity? - if so, how would I go about doing so?</p>
  
  <p>Ultimately I need to check a lot of fields and I cannot see how this can be done without lots of checks :/</p>