luni, 27 aprilie 2015

[OmniFaces utilities (2.0)] Check if the given string is null or is empty or contains whitespace only


[OmniFaces utilities] The isBlank() method returns true if the given string is null or is empty or contains whitespace only. In addition to #isEmpty(String), this thus also returns true when string.trim().isEmpty() returns true.

Method:
See also: Utils#isEmpty()
Usage:

import org.omnifaces.util.Utils;
...
String a = null;
String b="";
String c="   ";
String d="text";

boolean isABlank = Utils.isBlank(a);  // true
boolean isBBlank = Utils.isBlank(b);  // true
boolean isCBlank = Utils.isBlank(c);  // true
boolean isDBlank = Utils.isBlank(d);  // false

Niciun comentariu:

Trimiteți un comentariu