Class StringUtils


  • public class StringUtils
    extends Object
    Utils are responsible for basic operations with strings
    • Constructor Detail

      • StringUtils

        public StringUtils()
    • Method Detail

      • isEmpty

        public static boolean isEmpty​(String str)
        Is empty string
        Parameters:
        str -
        Returns:
        true if null or empty
      • isNotEmpty

        public static boolean isNotEmpty​(String str)
        Is not empty string
        Parameters:
        str -
        Returns:
        true if string not null and not empty
      • isBlank

        public static boolean isBlank​(CharSequence cs)
        Checks whether the input string null, empty or contains only white space characters.
        Parameters:
        cs - the input CharSequence, can be null
        Returns:
        true if the input string null or empty or contains only white space characters, false otherwise.
      • isNotBlank

        public static boolean isNotBlank​(CharSequence cs)
        Checks whether string is not blank.
        Parameters:
        cs - the input CharSequence, can be null
        Returns:
        true if the string is not blank, false otherwise.
        See Also:
        isBlank(CharSequence)
      • equalsTrimValues

        public static boolean equalsTrimValues​(String str1,
                                               String str2)
        Equals method for trimmed srings
        Parameters:
        str1 -
        str2 -
        Returns:
        true if strings are equal
      • equals

        public static boolean equals​(String str1,
                                     String str2)
      • uncapitalize

        public static String uncapitalize​(String source)
      • capitalize

        public static String capitalize​(String source)
        Sets the first character to the Upper case
        Parameters:
        source - - the source string
        Returns:
        the capitalized string
      • nameToText

        public static String nameToText​(String nameInput)
        Converts passed name input string into text string using next rules:
        1. A set of underline symbols ('_') changes to one empty symbol (space, ' ') If this symbol is first or last, it will be omitted
        2. Three and more upper case letters are not modified. Less than three upper case letters are placed in upper case if they are the last one in the string
        3. Before first upper case symbol, a space symbol is placed (only if there is no space before it)
        4. If there is a lower case or number symbol after one or two upper case symbols then upper case symbols are changed to lower case and there will be added a space symbol before them
        5. First character of a name is always in upper case
        Parameters:
        nameInput - - name of the element
        Returns:
        - text converted from name
      • removeExtension

        public static String removeExtension​(String s)
      • fuzzyMatch

        public static FuzzyPattern.Match fuzzyMatch​(String pattern,
                                                    String sample,
                                                    boolean useMutation)
        Performs fuzzy match given the pattern and sample.
        Parameters:
        pattern - pattern to match against, not null.
        sample - sample to match, not null.
        useMutation - use mutation (splitting) of pattern
        Returns:
        FuzzyPattern.Match.NONE if no match found, match describing the matched ranges otherwise, not null.
        See Also:
        FuzzyPattern
      • fuzzyMatch

        public static FuzzyPattern.Match fuzzyMatch​(String pattern,
                                                    String sample)
        Performs fuzzy match given the pattern and sample.
        Parameters:
        pattern - pattern to match against, not null.
        sample - sample to match, not null.
        Returns:
        FuzzyPattern.Match.NONE if no match found, match describing the matched ranges otherwise, not null
        See Also:
        FuzzyPattern
      • trimDigitSuffix

        public static String trimDigitSuffix​(String original)
        Gets the copy of original string with trailing digit removed.
        Parameters:
        original - - a prototype
        Returns:
        A copy of original string with trailing digit removed, or original string if it has no trailing digit.
      • isValidName

        public static boolean isValidName​(String name)
        Правильное имя свойства или метода контекста представляет собой строку ненулевой длины. Первый символ этой строки - буква или символ '_'. Все последующие символы должны быть буквами, десятичными цифрами или символами '_'
        Parameters:
        name - имя
        Returns:
      • lowerCaseHashCode

        public static int lowerCaseHashCode​(String str)
        Gets hashCode for lower case string.
        Parameters:
        str - the string.
        Returns:
        a hashCode of lower case string.
      • stringAsRegEx

        public static String stringAsRegEx​(String pattern)
        Escaped characters in string to use in regEx
        Parameters:
        pattern - - the input string (not null)
        Returns:
        an escaped string
      • processAmpersands

        public static Pair<String,​Integer> processAmpersands​(String string)
        Parses string with ampersands (if any) and returns modified string and position of first char that needs to be underlined.
        Parameters:
        string - original string, can be null or empty
        Returns:
        pair of result string and position of character that needs to be underlined in the result string, never null