title: Best way to verify string is empty or null
body: <p>i am sure this must have been asked before in different ways - as isEmptyOrNull is so common yet people implement it differently. but i have below curious query in terms of best available approach which is good for memory and performance both. </p>
  
  <p>1) Below does not account for all spaces like in case of empty XML tag</p>
  
  <pre><code>return inputString==null || inputString.length()==0;
  </code></pre>
  
  <p>2) Below one takes care but trim can eat some performance + memory </p>
  
  <pre><code>return inputString==null || inputString.trim().length()==0;
  </code></pre>
  
  <p>3) Combining one and two can save some performance + memory  (As Chris suggested in comments)</p>
  
  <pre><code>return inputString==null || inputString.trim().length()==0 || inputString.trim().length()==0;
  </code></pre>
  
  <p>4) Converted to pattern matcher (invoked only when string is non zero length)</p>
  
  <pre><code>private static final Pattern p = Pattern.compile("\\s+");
  
  return inputString==null || inputString.length()==0 || p.matcher(inputString).matches();
  </code></pre>
  
  <p>5) Using libraries like -
        Apache Commons (<code>StringUtils.isBlank/isEmpty</code>)
        or Spring (<code>StringUtils.isEmpty</code>) 
        or Guava (<code>Strings.isNullOrEmpty</code>) 
        or any other option?</p>