java.lang.Object
tech.deplant.java4ever.utils.Strings
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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
safeSubstr
(String originalStr, int beginIndex, int endIndex) static String
safeSubstr
(String originalStr, int beginIndex, int endIndex, boolean reversed) 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.
-
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
-
safeSubstr
-
safeSubstr
-
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
-