public static String trimWhitespace(final String userText) {
        if (userText == null || userText.isEmpty()) {
            return userText;
        } else {
            return userText.trim();
        }
    }
Null safe trimming of leading/trailing whitespace.
stroom-util-shared/src/main/java/stroom/util/shared/StringUtil.java