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