Class Strings

java.lang.Object
tech.deplant.java4ever.utils.Strings

public class Strings extends Object
  • Constructor Details

    • Strings

      public Strings()
  • Method Details

    • isEmpty

      public static boolean isEmpty(String str)
    • isNotEmpty

      public static boolean isNotEmpty(String str)
    • notEmpty

      public static String notEmpty(String str)
    • notEmpty

      public static String notEmpty(String str, String message)
    • notEmptyDo

      public static <T> void notEmptyDo(String str, Consumer<String> action)
    • notEmptyThrow

      public static <X extends Throwable> String notEmptyThrow(String str, Supplier<? extends X> exceptionSupplier) throws X
      Throws:
      X
    • notEmptyElse

      public static String notEmptyElse(String str, String defaultStr)
    • notEmptyElseLazy

      public static String notEmptyElseLazy(String str, Supplier<String> defaultSupplier)
    • notEmptyEquals

      public static boolean notEmptyEquals(String originalStr, String compareStr)
    • substr

      public static String substr(String originalStr, int beginIndex)
    • substr

      public static String substr(String originalStr, int beginIndex, int endIndex)
    • substr

      public static String substr(String originalStr, int beginIndex, boolean reversed)
    • substr

      public static String substr(String originalStr, int beginIndex, int endIndex, boolean reversed)
    • safeSubstrEquals

      public static boolean safeSubstrEquals(String originalStr, int beginIndex, int endIndex, boolean reversed, String compareStr)
      Safe means this method shouldn't ever fail, it will return false on nulls, empty strings, bad indexes and all other possible inconsistencies. True will be shown only if both string are non-empty and substr result is non-empty and originalStr and substr result are equal.
      Parameters:
      originalStr - original string that will be substred
      beginIndex - substr begin index
      endIndex - substr end index
      reversed - should be true if indexes should be counted backwards (from the end of the string)
      compareStr - string to compare with substring result
      Returns:
      result of comparison
    • base64StringToHexString

      public static String base64StringToHexString(String base64string)
    • padLeftZeros

      public static String padLeftZeros(String inputString, int length)
    • toHexString

      public static String toHexString(String text)
      Utility method for preparing hex strings
      Parameters:
      text - Text string to encode.
      Returns:
      Hex string
    • fromHexString

      public static String fromHexString(String text)