Class ObjectUtils
java.lang.Object
com.kingsrook.qqq.backend.core.utils.ObjectUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
ifCan
(UnsafeSupplier<Boolean, ? extends Throwable> supplier) Utility to test a chained unsafe expression CAN get to the end and return true.static <T> void
static <T,
E extends Exception>
voidifNotNullUnsafe
(T object, UnsafeConsumer<T, E> consumer) static <T> T
requireConditionElse
(T a, Predicate<T> condition, T b) static <T> T
requireNonNullElse
(T... objects) A varargs version of Objects.requireNonNullElsestatic <T> T
tryAndRequireNonNullElse
(UnsafeSupplier<T, ?> supplier, T defaultIfThrew) Like Objects.requireNonNullElse, only use an (unsafe) supplier as the first arg, and if it throws or returns null, then return the 2nd argstatic <T> T
tryElse
(UnsafeSupplier<T, ?> supplier, T defaultIfThrew) Like Objects.requireNonNullElse, only use an (unsafe) supplier as the first arg, and only if it throws, return the 2nd arg
-
Constructor Details
-
ObjectUtils
public ObjectUtils()
-
-
Method Details
-
requireNonNullElse
A varargs version of Objects.requireNonNullElse -
tryElse
Like Objects.requireNonNullElse, only use an (unsafe) supplier as the first arg, and only if it throws, return the 2nd arg -
tryAndRequireNonNullElse
Like Objects.requireNonNullElse, only use an (unsafe) supplier as the first arg, and if it throws or returns null, then return the 2nd arg -
ifNotNull
-
ifNotNullUnsafe
public static <T,E extends Exception> void ifNotNullUnsafe(T object, UnsafeConsumer<T, E> consumer) throws E- Throws:
E
-
requireConditionElse
-
ifCan
Utility to test a chained unsafe expression CAN get to the end and return true. e.g., instead of: if(a invalid input: '&'invalid input: '&' a.b invalid input: '&'invalid input: '&' a.b.c invalid input: '&'invalid input: '&' a.b.c.d) we can do: if(ifCan(() -> a.b.c.d)) Note - if the supplier returns null, that counts as false!
-