Package cn.longky.common.utils
Class CommonUtils
java.lang.Object
cn.longky.common.utils.CommonUtils
- Since:
- 1.0
- Author:
- yingzhan
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> booleancontains(T item, T... array) static StringencryptPassword(String password, String salt) static <T> TfirstMatch(Function<T, Boolean> matcher, T... args) static <T> TfirstMatchWithSuppliers(Function<T, Boolean> matcher, Supplier<T>... suppliers) static <T> TfirstNonnull(T... args) static <T> TfirstNonnull(T defaultValue, Supplier<T>... suppliers) static StringgenerateRandomString(int length, boolean isNumeric, boolean ignoreCase) static StringgenerateUniqueCodeByUid(long userId, int length, boolean isNumeric) static StringgenerateUniqueCodeByUid(long userId, int length, boolean isNumeric, int primeOfCharLength, long salt) static StringgetUuid()static Stringstatic Booleanstatic Integerstatic Longstatic <T> Tstatic <T> Tretry(KSupplier<T> supplier, int maxRetries, Duration sleepTime, Class<? extends Throwable> throwableClass, Predicate<T> verifier) static <T> Tretry(KSupplier<T> supplier, int maxRetries, Duration sleepTime, Class<? extends Throwable> throwableClass, Predicate<T> verifier, T defaultValue) static <T> Tstatic StringstringifySize(long size) static voidswallowException(KRunnable runnable) static <T> TswallowException(KSupplier<T> supplier) static booleanvalidatePassword(String rawPassword, String encryptedPassword, String salt)
-
Constructor Details
-
CommonUtils
public CommonUtils()
-
-
Method Details
-
safeCast
-
firstNonnull
-
firstNonnull
-
firstMatch
-
firstMatchWithSuppliers
@SafeVarargs public static <T> T firstMatchWithSuppliers(Function<T, Boolean> matcher, Supplier<T>... suppliers) -
swallowException
-
swallowException
-
getUuid
-
getUuid
-
contains
-
encryptPassword
-
validatePassword
-
generateRandomString
-
generateUniqueCodeByUid
public static String generateUniqueCodeByUid(long userId, int length, boolean isNumeric, int primeOfCharLength, long salt) -
generateUniqueCodeByUid
-
stringifySize
-
retry
- Throws:
Throwable
-
retry
public static <T> T retry(KSupplier<T> supplier, int maxRetries, Duration sleepTime, Class<? extends Throwable> throwableClass, Predicate<T> verifier) throws Throwable - Throws:
Throwable
-
retry
public static <T> T retry(KSupplier<T> supplier, int maxRetries, Duration sleepTime, Class<? extends Throwable> throwableClass, Predicate<T> verifier, T defaultValue) throws Throwable - Throws:
Throwable
-
parseLong
-
parseInt
-
parseBoolean
-