diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/StringUtils.java b/smack-core/src/main/java/org/jivesoftware/smack/util/StringUtils.java index 4b9bfe94c..c2650ebcc 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/util/StringUtils.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/util/StringUtils.java @@ -451,6 +451,16 @@ public class StringUtils { return cs; } + public static 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. *