title: Reducing the cyclomatic complexity, multiple if statements
body: <p>I have the following code:</p>
  
  <pre><code>private Facility updateFacility(Facility newFacility, Facility oldFacility) {
      if (newFacility.getCity() != null)
          oldFacility.setCity(newFacility.getCity());
      if (newFacility.getContactEmail() != null) 
          oldFacility.setContactEmail(newFacility.getContactEmail());
      if (newFacility.getContactFax() != null) 
          oldFacility.setContactFax(newFacility.getContactFax());
      if (newFacility.getContactName() != null) 
          oldFacility.setContactName(newFacility.getContactName());
      // ......
  }
  </code></pre>
  
  <p>There are around 14 such checks and assignments. That is, except for a few, I need to modify all the fields of the oldFacility object. I'm getting a cyclomatic complexity of this code 14, which is "greater than 10 authorized" as per SonarQube. Any ideas upon how to reduce the cyclomatic complexity?</p>