title: Solve Sonar issue in simple getter and setter methods with Date or List
body: <p>I write this getter/setter to list from Eclipse source menu:</p>
  
  <pre><code>public Date getDate() {
      return date;
  }
  
  public void setDate(Date date) {
      this.date = date;
  }
  </code></pre>
  
  <p>And Sonar reporting two issues: </p>
  
  <blockquote>
    <p>Return a copy of "date" &amp; Store a copy of "date"</p>
  </blockquote>
  
  <p>with the explanation </p>
  
  <blockquote>
    <p>"Mutable members should not be stored or returned directly"</p>
  </blockquote>
  
  <p>and a example code:</p>
  
  <pre><code>public String [] getStrings() {
      return strings.clone();}
  
  public void setStrings(String [] strings) {
      this.strings = strings.clone();}
  </code></pre>
  
  <p>I think if my Date is null, it will throw a NullPointerException. Then I've changed my code to:</p>
  
  <pre><code>public Date getDate() {
      if (this.date != null) {
          return new Date(this.date.getTime());
      } else {
          return null;
      }
  }
  
  public void setDate(Date date) {
      if (date != null) {
          this.date = new Date(date.getTime());
      } else {
          this.date = null;
      }
  }
  </code></pre>
  
  <p>And now marks other issue: </p>
  
  <blockquote>
    <p>"Assigning an Object to null is a code smell. Consider refactoring".</p>
  </blockquote>
  
  <p>I've searched in internet and set or return a new array is not a solution for me, I want to preserve my list to null if the setter param is null to overwrite an existing previous list.</p>
  
  <p>I've the same problem for List, and I want to return/preserve null instead of a new ArrayList for an empty List. And in this case, the setter marks one more issue: </p>
  
  <blockquote>
    <p>"Return an empty collection instead of null.".</p>
  </blockquote>
  
  <p>What is the solution for this issue?</p>