Package io.dingodb.sdk.common.utils
Class Parameters
java.lang.Object
io.dingodb.sdk.common.utils.Parameters
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TIf check function return is false, throw exception, else return input.static <T> Tcheck(T input, Predicate<T> checkFunction, Supplier<RuntimeException> throwableSupplier) If check function return is false, throw exception, else return input.static <T> TIf check function return is false, return default value, else return input.static <T> TIf check function return is false, return default value, else return input.static <T> TIf check function return is false, return default value, else return input.static <T> TcleanNull(T input, T defaultValue) If check function return is false, return default value, else return input.static <T> @NonNull TIf input is null, throwNullPointerException, else return input.static <E,C extends Collection<E>>
@NonNull CIf input is null or empty, throwIllegalArgumentException, else return input.
-
Method Details
-
nonNull
If input is null, throwNullPointerException, else return input.- Type Parameters:
T- input type- Parameters:
input- check objectmessage- exception message if input is null- Returns:
- input
-
notEmpty
If input is null or empty, throwIllegalArgumentException, else return input.- Type Parameters:
C- input collection type- Parameters:
input- check objectmessage- exception message if input is null- Returns:
- input
-
check
If check function return is false, throw exception, else return input.- Type Parameters:
T- input type- Parameters:
input- check objectcheckFunction- check functionmessage- error message- Returns:
- input
-
check
public static <T> T check(T input, Predicate<T> checkFunction, Supplier<RuntimeException> throwableSupplier) If check function return is false, throw exception, else return input.- Type Parameters:
T- input type- Parameters:
input- check objectcheckFunction- check functionthrowableSupplier- throwable supplier- Returns:
- input
-
cleanNull
public static <T> T cleanNull(T input, T defaultValue) If check function return is false, return default value, else return input.- Type Parameters:
T- input type- Parameters:
input- check objectdefaultValue- default value- Returns:
- input
-
cleanNull
If check function return is false, return default value, else return input.- Type Parameters:
T- input type- Parameters:
input- check objectvalueSupplier- default value supplier- Returns:
- input
-
clean
If check function return is false, return default value, else return input.- Type Parameters:
T- input type- Parameters:
input- check objectcheckFunction- check functionvalueSupplier- default value supplier- Returns:
- input
-
clean
If check function return is false, return default value, else return input.- Type Parameters:
T- input type- Parameters:
input- check objectcheckFunction- check functiondefaultValue- default value supplier- Returns:
- input
-