1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-26 05:52:06 +01:00

Add StringUtils.requireNullOrNotEmpty()

This commit is contained in:
Florian Schmaus 2018-06-07 17:55:00 +02:00
parent 414d730962
commit c792be9267

View file

@ -451,6 +451,16 @@ public class StringUtils {
return cs; 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. * Return the String representation of the given char sequence if it is not null.
* *