title: How to determine if a list of string contains null or empty elements
body: <p>In Java, I have the following method:</p>
  
  <pre><code>public String normalizeList(List&lt;String&gt; keys) {
      // ...
  }
  </code></pre>
  
  <p>I want to check that <code>keys</code>:</p>
  
  <ul>
  <li>Is not <code>null</code> itself; and</li>
  <li>Is not empty (<code>size() == 0</code>); and</li>
  <li>Does not have any <code>String</code> elements that are <code>null</code>; and</li>
  <li>Does not have any <code>String</code> elements that are empty ("")</li>
  </ul>
  
  <p>This is a utility method that will go in a "commons"-style JAR (the class wil be something like <code>DataUtils</code>). Here is what I have, but I believe its incorrect:</p>
  
  <pre><code>public String normalize(List&lt;String&gt; keys) {
      if(keys == null || keys.size() == 0 || keys.contains(null) || keys.contains(""))
          throw new IllegalArgumentException("Bad!");
  
      // Rest of method...
  }
  </code></pre>
  
  <p>I believe the last 2 checks for <code>keys.contains(null)</code> and <code>keys.contains("")</code> are incorrect and will likely thrown runtime exceptions. <strong>I know I can just loop through the list inside the <code>if</code> statement, and check for nulls/empties there, but I'm looking for a more elegant solution if it exists.</strong></p>