java.lang.Object
tech.deplant.java4ever.utils.Strings
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
base64StringToHexString
(String base64string) static String
fromHexString
(String text) static boolean
static boolean
isNotEmpty
(String str) static String
static String
static <T> void
notEmptyDo
(String str, Consumer<String> action) static String
notEmptyElse
(String str, String defaultStr) static String
notEmptyElseLazy
(String str, Supplier<String> defaultSupplier) static boolean
notEmptyEquals
(String originalStr, String compareStr) notEmptyThrow
(String str, Supplier<? extends X> exceptionSupplier) static String
padLeftZeros
(String inputString, int length) 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.static String
static String
static String
static String
static String
toHexString
(String text) Utility method for preparing hex strings
-
Constructor Details
-
Strings
public Strings()
-
-
Method Details
-
isEmpty
-
isNotEmpty
-
notEmpty
-
notEmpty
-
notEmptyDo
-
notEmptyThrow
public static <X extends Throwable> String notEmptyThrow(String str, Supplier<? extends X> exceptionSupplier) throws X - Throws:
X
-
notEmptyElse
-
notEmptyElseLazy
-
notEmptyEquals
-
substr
-
substr
-
substr
-
substr
-
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 substredbeginIndex
- substr begin indexendIndex
- substr end indexreversed
- 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
-
padLeftZeros
-
toHexString
Utility method for preparing hex strings- Parameters:
text
- Text string to encode.- Returns:
- Hex string
-
fromHexString
-