From c792be92675803684477f7ff235baaf74ef85cfd Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Thu, 7 Jun 2018 17:55:00 +0200 Subject: [PATCH] Add StringUtils.requireNullOrNotEmpty() --- .../java/org/jivesoftware/smack/util/StringUtils.java | 10 ++++++++++ 1 file changed, 10 insertions(+) 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. *