title: Iterator null collection
body: <p>It's quite common that I have to check null before iterate when not sure the collection reference is null or not.
  Sample:</p>
  
  <pre><code>Collection&lt;Object&gt; collection = ...
  ...
  if(collection != null)//troublesome
      for(Object o : collection)
  </code></pre>
  
  <p>Of course, I know empty collection is much better than null, but in some cases client code cannot control the nullable collection from other modules (for instance, return value from 3rd party code).
  So I wrote a utility method:</p>
  
  <pre><code>public static &lt;T&gt; Iterable&lt;T&gt; nullableIterable(Iterable&lt;T&gt; it){
      return it != null ? it : Collections.&lt;T&gt;emptySet();
  }
  </code></pre>
  
  <p>In client code, no need to check null any more:</p>
  
  <pre><code>for(Object o : nullableIterable(collection))
  ...
  </code></pre>
  
  <p>Do you think <code>nullableIterable()</code> is reasonable? Any advice? Any concern? Thanks!</p>