Add StringUtils.requireNullOrNotEmpty()

This commit is contained in:
Florian Schmaus 2018-06-07 17:55:00 +02:00
parent 414d730962
commit c792be9267
1 changed files with 10 additions and 0 deletions

View File

@ -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.
*