java.lang.Object
tech.deplant.java4ever.utils.Strings
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringbase64StringToHexString(String base64string) static StringfromHexString(String text) static booleanstatic booleanisNotEmpty(String str) static Stringstatic Stringstatic <T> voidnotEmptyDo(String str, Consumer<String> action) static StringnotEmptyElse(String str, String defaultStr) static StringnotEmptyElseLazy(String str, Supplier<String> defaultSupplier) static booleannotEmptyEquals(String originalStr, String compareStr) notEmptyThrow(String str, Supplier<? extends X> exceptionSupplier) static StringpadLeftZeros(String inputString, int length) static booleansafeSubstrEquals(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 Stringstatic Stringstatic Stringstatic Stringstatic StringtoHexString(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 extends Throwable
-
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
-