How to check List <String> for null or null?
It seems that I am doing, I am getting the wrong result.
My list is defined as follows:
private List<String> selectedPriorities; Nothing odd or fantastic on getter / setter:
public void setSelectedPriorities(List<String> selectedPriorities) { this.selectedPriorities = selectedPriorities; } public List<String> getSelectedPriorities() { return selectedPriorities; } In a bean session, I want to change another List based on the content (or lack thereof) of this list.
Here is the code:
List<String> restrictList = new ArrayList<String>(); 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()<1){ System.out.println("HAS NOTHING IN IT"); return restrictList; } System.out.println("NOT NULL"); restrictList.add("lower(logs.priority) in (#{prioritySelectorBean.selectedPriorities})"); It always drops to NOT NULL and adds a string to limit the List. It makes me crazy! How do I discover anything on this list? Here is a snippet of the magazine
14:24:10,057 INFO [STDOUT] constructRestrictionList selectorBean [] 14:24:10,057 INFO [STDOUT] NOT NULL +4
2 answers