How to test List<String> for empty or nullness?
<p>It seems no matter what I do I get the wrong result.</p>

<p>My list is defined as follows:</p>

<pre><code>private List&lt;String&gt; selectedPriorities;
</code></pre>

<p>Nothing odd or fancy on the getter/setter:</p>

<pre><code>public void setSelectedPriorities(List&lt;String&gt; selectedPriorities) {
    this.selectedPriorities = selectedPriorities;
}

public List&lt;String&gt; getSelectedPriorities() {
    return selectedPriorities;
}
</code></pre>

<p>In a session bean I want to alter a different List based on the contents (or lack thereof) of this list.</p>

<p>Here is that code:</p>

<pre><code>List&lt;String&gt; restrictList = new ArrayList&lt;String&gt;();
restrictList.add("lower(logs.clazz) like lower(concat(#{logs.clazz},'%'))");
restrictList.add("lower(logs.rule) like lower(concat(#{logs.rule},'%'))");
PrioritySelectorBean selectorBean = (PrioritySelectorBean) Component.getInstance("prioritySelectorBean",true);
System.out.println("constructRestrictionList selectorBean "+selectorBean.getSelectedPriorities());

if (selectorBean.getSelectedPriorities() == null) {
    System.out.println("IS NULL");
    return restrictList;
}

if (selectorBean.getSelectedPriorities().isEmpty()){
    System.out.println("IS EMPTY");
}

if (selectorBean.getSelectedPriorities().size()&lt;1){
    System.out.println("HAS NOTHING IN IT");
    return restrictList;
}
System.out.println("NOT NULL");
restrictList.add("lower(logs.priority) in (#{prioritySelectorBean.selectedPriorities})");
</code></pre>

<p>It always falls through to NOT NULL and adds the string to restrictList.  It's making me crazy! How do I detect nothingness in this list? Here is the log snippet</p>

<pre><code>14:24:10,057 INFO  [STDOUT] constructRestrictionList selectorBean []
14:24:10,057 INFO  [STDOUT] NOT NULL
</code></pre>
