Class Strings


  • public final class Strings
    extends Object
    • Method Detail

      • isNullOrEmpty

        public static boolean isNullOrEmpty​(String str)
      • isNotNullOrEmpty

        public static boolean isNotNullOrEmpty​(String str)
      • indexOfAlphabetic

        public static int indexOfAlphabetic​(String str)
      • capitalizeFirst

        public static String capitalizeFirst​(String str)
      • deCapitalizeFirst

        public static String deCapitalizeFirst​(String str)
      • join

        public static <T> String join​(T[] items,
                                      String delimiter)
      • loadResourceQuietly

        public static final String loadResourceQuietly​(String resourceName)
      • loadResourceQuietly

        public static final String loadResourceQuietly​(URL resourceUrl)
      • compact

        public static final String compact​(String name)
        Remove repeating strings that are appearing in the name. This is done by splitting words (camel case) and using each word once.
        Parameters:
        name - The name to compact.
        Returns:
        The compact name.
      • prefixKeywords

        public static final String prefixKeywords​(String name)
        Adds an underscore to the specified String, if its a Java Keyword.
        Parameters:
        name - The specified string.
        Returns:
        The specified string if not a keyword, the string prefixed with underscore otherwise.
      • toFieldName

        public static final String toFieldName​(String name)
        Converts the string into a safe field name.
        Parameters:
        name - The field name.
        Returns:
        The safe field name.
      • camelCase

        public static final String camelCase​(String name)
        Converts the given string to camelCase format.

        This method takes a string input and converts it to camelCase format, where each word in the input string is capitalized (except the first word) and concatenated together without spaces. Non-alphanumeric characters are treated as word separators.

        If the input string is null, null is returned. If the input string is empty or contains only non-alphanumeric characters, an empty string is returned.

        For example:

        
         camelCase("helloWorld") returns "helloWorld"
         camelCase("hello_world") returns "helloWorld"
         camelCase("hello world") returns "helloWorld"
         camelCase("foo-bar-baz") returns "fooBarBaz"
         camelCase("123_456_789") returns "123456789"
         camelCase("   ") returns ""
         camelCase(null) returns null
         
        Parameters:
        name - the string to convert to camelCase
        Returns:
        the input string converted to camelCase format, or null if the input string is null, or an empty string if the input string is empty or contains only non-alphanumeric characters
      • toPojoName

        public static final String toPojoName​(String name,
                                              String prefix,
                                              String suffix)
        Converts a name of an interface or abstract class to Pojo name. Remove leading "I" and "Abstract" or trailing "Interface".
        Parameters:
        name - The name to convert.
        prefix - The prefix to use if needed.
        suffix - The suffix to user if needed.
        Returns:
        The converted name, if a conversion actually happened or the original name prefixed and suffixed otherwise.