mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 20:12:07 +01:00
Add StringUtils.requireNullOrNotEmpty()
This commit is contained in:
parent
414d730962
commit
c792be9267
1 changed files with 10 additions and 0 deletions
|
@ -451,6 +451,16 @@ public class StringUtils {
|
|||
return cs;
|
||||
}
|
||||
|
||||
public static <CS extends CharSequence> CS requireNullOrNotEmpty(CS cs, String message) {
|
||||
if (cs == null) {
|
||||
return null;
|
||||
}
|
||||
if (cs.toString().isEmpty()) {
|
||||
throw new IllegalArgumentException(message);
|
||||
}
|
||||
return cs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the String representation of the given char sequence if it is not null.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue