1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-22 06:12:05 +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.
* *