@Test public void testIsEmpty() { assertTrue(StringUtil.isEmpty(null)); assertTrue(StringUtil.isEmpty("")); assertFalse(StringUtil.isEmpty("a")); assertFalse(StringUtil.isEmpty(" ")); assertFalse(StringUtil.isEmpty(" ")); assertFalse(StringUtil.isEmpty(" a")); assertFalse(StringUtil.isEmpty("z ")); assertFalse(StringUtil.isEmpty("тест")); }
@Contract(value = "null -> true", pure = true) public static boolean isEmpty(@Nullable String s) { return s == null || s.isEmpty(); }
StringUtil { @Contract(value = "null -> true", pure = true) public static boolean isEmpty(@Nullable String s) { return s == null || s.isEmpty(); } }
StringUtil { @Contract(value = "null -> true", pure = true) public static boolean isEmpty(@Nullable String s) { return s == null || s.isEmpty(); } private  StringUtil(); }
StringUtil { @Contract(value = "null -> true", pure = true) public static boolean isEmpty(@Nullable String s) { return s == null || s.isEmpty(); } private  StringUtil(); static boolean isWhitespace(char c); static boolean isPrintable(char c); @Contract("null -> null") @Nullable static String replaceInvisibleCharacters(@Nullable String s); @Contract("null, _ -> null") @Nullable static String replaceInvisibleCharacters(@Nullable String s, char replacement); @Contract(pure = true) static boolean isCyrillic(char c); @Contract("null -> false") static boolean isCyrillic(@Nullable String s); static double getCyrillicFactor(@Nullable String s); @Contract(value = "null -> true", pure = true) static boolean isEmpty(@Nullable String s); @Contract(value = "null -> false", pure = true) static boolean isNotEmpty(@Nullable String s); @Contract("null -> true") static boolean isBlank(@Nullable String s); @Contract("null -> false") static boolean isNotBlank(@Nullable String s); @Contract(value = "null, null -> true; null, !null -> false; !null, null -> false", pure = true) static boolean equals(@Nullable String stringA, @Nullable String stringB); static boolean equalsOrEmpty(@Nullable String stringA, @Nullable String stringB); static boolean equalsOrBlank(@Nullable String stringA, @Nullable String stringB); @Contract("null, null -> true; null, !null -> false; !null, null -> false") static boolean equalsIgnoreCase(@Nullable String stringA, @Nullable String stringB); static boolean equalsOrEmptyIgnoreCase(@Nullable String stringA, @Nullable String stringB); static boolean equalsOrBlankIgnoreCase(@Nullable String stringA, @Nullable String stringB); @Contract(value = "null, null -> false; null, !null -> true; !null, null -> true", pure = true) static boolean notEquals(@Nullable String stringA, @Nullable String stringB); static boolean notEqualsOrEmpty(@Nullable String stringA, @Nullable String stringB); static boolean notEqualsOrBlank(@Nullable String stringA, @Nullable String stringB); @Contract("null, null -> false; null, !null -> true; !null, null -> true") static boolean notEqualsIgnoreCase(@Nullable String stringA, @Nullable String stringB); static boolean notEqualsOrEmptyIgnoreCase(@Nullable String stringA, @Nullable String stringB); static boolean notEqualsOrBlankIgnoreCase(@Nullable String stringA, @Nullable String stringB); @Contract(pure = true) static int length(@Nullable String s); @Contract(pure = true) @Nonnull static String nullToEmpty(@Nullable String s); @Contract(value = "null -> null", pure = true) @Nullable static String emptyToNull(@Nullable String s); @Contract(value = "!null, _ -> ! null; _, !null -> ! null", pure = true) @Nullable static String nullToDefault(@Nullable String s, @Nullable String defaultValue); @Contract(value = "null -> null; !null -> !null", pure = true) @Nullable static String trim(@Nullable String s); @Contract(value = "null -> null", pure = true) @Nullable static String trimToNull(@Nullable String s); @Contract(pure = true) @Nonnull static String trimToEmpty(@Nullable String s); @Contract(value = "null -> null; !null -> !null", pure = true) @Nullable static String trimRight(@Nullable String s); @Contract(value = "null -> null", pure = true) @Nullable static String trimRightToNull(@Nullable String s); @Contract(pure = true) @Nonnull static String trimRightToEmpty(@Nullable String s); @Contract(value = "null -> null; !null -> !null", pure = true) @Nullable static String trimLeft(@Nullable String s); @Contract(value = "null -> null", pure = true) @Nullable static String trimLeftToNull(@Nullable String s); @Contract(pure = true) @Nonnull static String trimLeftToEmpty(@Nullable String s); @Contract(value = "null, _ -> false", pure = true) static boolean startsWith(@Nullable String s, @Nonnull String prefix); @Contract(value = "null, _ -> false", pure = true) static boolean endsWith(@Nullable String s, @Nonnull String suffix); @Nonnull static String[] split(@Nonnull String s, char separator); @Nonnull static String[] tokenize(@Nonnull String s); @Contract(value = "null, _, _ -> null; !null, _, _ -> !null", pure = true) @Nullable static String replace(@Nullable String s, @Nullable String target, @Nullable String replacement); @SuppressWarnings({"OverloadedVarargsMethod", "AccessingNonPublicFieldOfAnotherObject"}) @Nonnull static String toString(
            @Nonnull Class<? extends T> objectClass, @Nullable T object, boolean skipNulls, String... fieldNames); @SuppressWarnings({"OverloadedVarargsMethod", "AccessingNonPublicFieldOfAnotherObject"}) @Nonnull static String toString(
            @Nonnull Class<? extends T> objectClass, @Nullable T object, @Nonnull ToStringOptions options,
            String... fieldNames); @SuppressWarnings({"OverloadedVarargsMethod", "AccessingNonPublicFieldOfAnotherObject"}) @Nonnull static String toString(@Nonnull Object object, boolean skipNulls, String... fieldNames); @SuppressWarnings({"OverloadedVarargsMethod", "AssignmentToMethodParameter", "AccessingNonPublicFieldOfAnotherObject"}) @Nonnull static String toString(@Nonnull Object object, @Nonnull ToStringOptions options, String... fieldNames); @SuppressWarnings("unchecked") @Nullable static ToStringConverter<? super T> getToStringConverter(
            @Nonnull Class<T> valueClass, boolean checkSuperclasses); @SuppressWarnings("unchecked") static ToStringConverter<T> registerToStringConverter(
            @Nonnull Class<T> valueClass, @Nonnull ToStringConverter<T> converter, boolean overwrite); @Contract("null -> null") @Nullable static String stripSpaces(@Nullable String s); @Contract("null, _ -> null") @Nullable static String removeCharOccurrences(@Nullable String s, char charToRemove); @SuppressWarnings("OverlyNestedMethod") static SortedSet<Integer> parseIntegers(String s); @Nonnull static String formatIntegers(@Nonnull Collection<Integer> numbers); @Nonnull static String formatIntegers(
            @Nonnull Collection<Integer> numbers, @Nonnull String itemSeparator, @Nonnull String intervalSeparator); static String quoteHtml(String html); @Nonnull static String formatComments(String comment); @SuppressWarnings({"HardcodedLineSeparator"}) @Nonnull static String toWindowsLineBreaks(String s); static String toUnixLineBreaks(String s); static String wellformForWindows(String s); static void convertFileToLinuxStyle(File file); @Contract(value = "!null, _ -> !null", pure = true) @Nullable static String cropTo(@Nullable String s, int maxLength); @Contract(value = "!null, _ -> !null", pure = true) @Nullable static String shrinkTo(@Nullable String s, int maxLength); @SuppressWarnings("Convert2streamapi") @Nullable static List<String> shrinkLinesTo(List<String> lines, int maxLineLength, int maxLineCount); @Contract("!null, _, _ -> !null") @Nullable static String[] shrinkLinesTo(String[] lines, int maxLineLength, int maxLineCount); static String cropLines(String input, int maxLineLength, int maxLineNumber); @Contract("null -> false") static boolean containsRussianLetters(@Nullable String s); @Nonnull static byte[] sha1(byte[] input); @Nonnull static String sha1Hex(byte[] input); @Nonnull static byte[] sha1(@Nonnull String s); @Nonnull static String sha1Hex(@Nonnull String s); static String sha1Base64(byte[] input); static String sha1Base64UrlSafe(byte[] input); static byte[] hmacSha1(byte[] value, byte[] key); @Nonnull static String hmacSha1Hex(byte[] value, byte[] key); static String hmacSha1Base64(byte[] value, byte[] key); static String hmacSha1Base64UrlSafe(byte[] value, byte[] key); static String subscribe(String plainText, String secretKey); static String unsubscribe(String subscribedText, String secretKey); @SuppressWarnings("Duplicates") @Nonnull static String hexEncrypt(@Nonnull String text, @Nonnull String secretKey); @SuppressWarnings("Duplicates") @Nonnull static String hexDecrypt(@Nonnull String text, @Nonnull String secretKey); @SuppressWarnings({"OverlyComplexMethod", "OverlyLongMethod"}) static int compareStringsSmart(@Nonnull String stringA, @Nonnull String stringB); static void sortStringsSmart(@Nonnull String[] strings); static void sortStringsSmart(@Nonnull List<String> strings); static long longHashCode(@Nullable String s); @Contract(value = "null -> null; !null -> !null", pure = true) @Nullable static String escapeJavaRetainCyrillic(@Nullable String s); @SuppressWarnings({"OverlyComplexMethod", "OverlyLongMethod", "SwitchStatementWithTooManyBranches"}) @Contract(value = "null -> null; !null -> !null", pure = true) @Nullable static String escapeMySqlString(@Nullable String s); @SuppressWarnings({"IfStatementWithIdenticalBranches", "OverlyComplexMethod", "AssignmentOrReturnOfFieldWithMutableType"}) @Contract("null -> null; !null -> !null") @Nullable static byte[] removeBoms(@Nullable byte[] bytes); static void ifNotEmpty(@Nullable String s, @Nonnull Consumer<String> consumer); static void ifNotBlank(@Nullable String s, @Nonnull Consumer<String> consumer); @Contract(value = " -> fail", pure = true) static String firstNonNull(); @Contract(value = "null -> fail; !null -> param1", pure = true) static String firstNonNull(String string); @Contract(value = "!null, _ -> param1; null, !null -> param2; null, null -> fail", pure = true) static String firstNonNull(String string1, String string2); @Contract(value = "null -> fail", pure = true) static String firstNonNull(String... strings); @Nonnull static String convertHtmlToText(@Nonnull String html); }
StringUtil { @Contract(value = "null -> true", pure = true) public static boolean isEmpty(@Nullable String s) { return s == null || s.isEmpty(); } private  StringUtil(); static boolean isWhitespace(char c); static boolean isPrintable(char c); @Contract("null -> null") @Nullable static String replaceInvisibleCharacters(@Nullable String s); @Contract("null, _ -> null") @Nullable static String replaceInvisibleCharacters(@Nullable String s, char replacement); @Contract(pure = true) static boolean isCyrillic(char c); @Contract("null -> false") static boolean isCyrillic(@Nullable String s); static double getCyrillicFactor(@Nullable String s); @Contract(value = "null -> true", pure = true) static boolean isEmpty(@Nullable String s); @Contract(value = "null -> false", pure = true) static boolean isNotEmpty(@Nullable String s); @Contract("null -> true") static boolean isBlank(@Nullable String s); @Contract("null -> false") static boolean isNotBlank(@Nullable String s); @Contract(value = "null, null -> true; null, !null -> false; !null, null -> false", pure = true) static boolean equals(@Nullable String stringA, @Nullable String stringB); static boolean equalsOrEmpty(@Nullable String stringA, @Nullable String stringB); static boolean equalsOrBlank(@Nullable String stringA, @Nullable String stringB); @Contract("null, null -> true; null, !null -> false; !null, null -> false") static boolean equalsIgnoreCase(@Nullable String stringA, @Nullable String stringB); static boolean equalsOrEmptyIgnoreCase(@Nullable String stringA, @Nullable String stringB); static boolean equalsOrBlankIgnoreCase(@Nullable String stringA, @Nullable String stringB); @Contract(value = "null, null -> false; null, !null -> true; !null, null -> true", pure = true) static boolean notEquals(@Nullable String stringA, @Nullable String stringB); static boolean notEqualsOrEmpty(@Nullable String stringA, @Nullable String stringB); static boolean notEqualsOrBlank(@Nullable String stringA, @Nullable String stringB); @Contract("null, null -> false; null, !null -> true; !null, null -> true") static boolean notEqualsIgnoreCase(@Nullable String stringA, @Nullable String stringB); static boolean notEqualsOrEmptyIgnoreCase(@Nullable String stringA, @Nullable String stringB); static boolean notEqualsOrBlankIgnoreCase(@Nullable String stringA, @Nullable String stringB); @Contract(pure = true) static int length(@Nullable String s); @Contract(pure = true) @Nonnull static String nullToEmpty(@Nullable String s); @Contract(value = "null -> null", pure = true) @Nullable static String emptyToNull(@Nullable String s); @Contract(value = "!null, _ -> ! null; _, !null -> ! null", pure = true) @Nullable static String nullToDefault(@Nullable String s, @Nullable String defaultValue); @Contract(value = "null -> null; !null -> !null", pure = true) @Nullable static String trim(@Nullable String s); @Contract(value = "null -> null", pure = true) @Nullable static String trimToNull(@Nullable String s); @Contract(pure = true) @Nonnull static String trimToEmpty(@Nullable String s); @Contract(value = "null -> null; !null -> !null", pure = true) @Nullable static String trimRight(@Nullable String s); @Contract(value = "null -> null", pure = true) @Nullable static String trimRightToNull(@Nullable String s); @Contract(pure = true) @Nonnull static String trimRightToEmpty(@Nullable String s); @Contract(value = "null -> null; !null -> !null", pure = true) @Nullable static String trimLeft(@Nullable String s); @Contract(value = "null -> null", pure = true) @Nullable static String trimLeftToNull(@Nullable String s); @Contract(pure = true) @Nonnull static String trimLeftToEmpty(@Nullable String s); @Contract(value = "null, _ -> false", pure = true) static boolean startsWith(@Nullable String s, @Nonnull String prefix); @Contract(value = "null, _ -> false", pure = true) static boolean endsWith(@Nullable String s, @Nonnull String suffix); @Nonnull static String[] split(@Nonnull String s, char separator); @Nonnull static String[] tokenize(@Nonnull String s); @Contract(value = "null, _, _ -> null; !null, _, _ -> !null", pure = true) @Nullable static String replace(@Nullable String s, @Nullable String target, @Nullable String replacement); @SuppressWarnings({"OverloadedVarargsMethod", "AccessingNonPublicFieldOfAnotherObject"}) @Nonnull static String toString(
            @Nonnull Class<? extends T> objectClass, @Nullable T object, boolean skipNulls, String... fieldNames); @SuppressWarnings({"OverloadedVarargsMethod", "AccessingNonPublicFieldOfAnotherObject"}) @Nonnull static String toString(
            @Nonnull Class<? extends T> objectClass, @Nullable T object, @Nonnull ToStringOptions options,
            String... fieldNames); @SuppressWarnings({"OverloadedVarargsMethod", "AccessingNonPublicFieldOfAnotherObject"}) @Nonnull static String toString(@Nonnull Object object, boolean skipNulls, String... fieldNames); @SuppressWarnings({"OverloadedVarargsMethod", "AssignmentToMethodParameter", "AccessingNonPublicFieldOfAnotherObject"}) @Nonnull static String toString(@Nonnull Object object, @Nonnull ToStringOptions options, String... fieldNames); @SuppressWarnings("unchecked") @Nullable static ToStringConverter<? super T> getToStringConverter(
            @Nonnull Class<T> valueClass, boolean checkSuperclasses); @SuppressWarnings("unchecked") static ToStringConverter<T> registerToStringConverter(
            @Nonnull Class<T> valueClass, @Nonnull ToStringConverter<T> converter, boolean overwrite); @Contract("null -> null") @Nullable static String stripSpaces(@Nullable String s); @Contract("null, _ -> null") @Nullable static String removeCharOccurrences(@Nullable String s, char charToRemove); @SuppressWarnings("OverlyNestedMethod") static SortedSet<Integer> parseIntegers(String s); @Nonnull static String formatIntegers(@Nonnull Collection<Integer> numbers); @Nonnull static String formatIntegers(
            @Nonnull Collection<Integer> numbers, @Nonnull String itemSeparator, @Nonnull String intervalSeparator); static String quoteHtml(String html); @Nonnull static String formatComments(String comment); @SuppressWarnings({"HardcodedLineSeparator"}) @Nonnull static String toWindowsLineBreaks(String s); static String toUnixLineBreaks(String s); static String wellformForWindows(String s); static void convertFileToLinuxStyle(File file); @Contract(value = "!null, _ -> !null", pure = true) @Nullable static String cropTo(@Nullable String s, int maxLength); @Contract(value = "!null, _ -> !null", pure = true) @Nullable static String shrinkTo(@Nullable String s, int maxLength); @SuppressWarnings("Convert2streamapi") @Nullable static List<String> shrinkLinesTo(List<String> lines, int maxLineLength, int maxLineCount); @Contract("!null, _, _ -> !null") @Nullable static String[] shrinkLinesTo(String[] lines, int maxLineLength, int maxLineCount); static String cropLines(String input, int maxLineLength, int maxLineNumber); @Contract("null -> false") static boolean containsRussianLetters(@Nullable String s); @Nonnull static byte[] sha1(byte[] input); @Nonnull static String sha1Hex(byte[] input); @Nonnull static byte[] sha1(@Nonnull String s); @Nonnull static String sha1Hex(@Nonnull String s); static String sha1Base64(byte[] input); static String sha1Base64UrlSafe(byte[] input); static byte[] hmacSha1(byte[] value, byte[] key); @Nonnull static String hmacSha1Hex(byte[] value, byte[] key); static String hmacSha1Base64(byte[] value, byte[] key); static String hmacSha1Base64UrlSafe(byte[] value, byte[] key); static String subscribe(String plainText, String secretKey); static String unsubscribe(String subscribedText, String secretKey); @SuppressWarnings("Duplicates") @Nonnull static String hexEncrypt(@Nonnull String text, @Nonnull String secretKey); @SuppressWarnings("Duplicates") @Nonnull static String hexDecrypt(@Nonnull String text, @Nonnull String secretKey); @SuppressWarnings({"OverlyComplexMethod", "OverlyLongMethod"}) static int compareStringsSmart(@Nonnull String stringA, @Nonnull String stringB); static void sortStringsSmart(@Nonnull String[] strings); static void sortStringsSmart(@Nonnull List<String> strings); static long longHashCode(@Nullable String s); @Contract(value = "null -> null; !null -> !null", pure = true) @Nullable static String escapeJavaRetainCyrillic(@Nullable String s); @SuppressWarnings({"OverlyComplexMethod", "OverlyLongMethod", "SwitchStatementWithTooManyBranches"}) @Contract(value = "null -> null; !null -> !null", pure = true) @Nullable static String escapeMySqlString(@Nullable String s); @SuppressWarnings({"IfStatementWithIdenticalBranches", "OverlyComplexMethod", "AssignmentOrReturnOfFieldWithMutableType"}) @Contract("null -> null; !null -> !null") @Nullable static byte[] removeBoms(@Nullable byte[] bytes); static void ifNotEmpty(@Nullable String s, @Nonnull Consumer<String> consumer); static void ifNotBlank(@Nullable String s, @Nonnull Consumer<String> consumer); @Contract(value = " -> fail", pure = true) static String firstNonNull(); @Contract(value = "null -> fail; !null -> param1", pure = true) static String firstNonNull(String string); @Contract(value = "!null, _ -> param1; null, !null -> param2; null, null -> fail", pure = true) static String firstNonNull(String string1, String string2); @Contract(value = "null -> fail", pure = true) static String firstNonNull(String... strings); @Nonnull static String convertHtmlToText(@Nonnull String html);  }