java.lang.Object
tech.deplant.java4ever.utils.Objs
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <OUT,
IN> OUT decode
(IN obj, IN compare, OUT then, OUT orElse) static boolean
static boolean
static boolean
static <T> T
notNull
(T obj) Throws NullPointerException if object is nullstatic <T> T
Throws NullPointerException with provided message if object is nullstatic <X extends Throwable,
T>
TThrows custom exception if object is nullstatic <T> void
static <T> T
notNullElse
(T obj, T defaultObj) Replaces importing of Objects.requireNonNullElse() Returns defaultObj if obj is nullstatic <T> T
notNullElseLazy
(T obj, Supplier<? extends T> supplier) static <T,
R> R notNullReplaceElse
(T obj, R replaceObj, R defaultObj) If not null returns replaceObj, if null returns defaultObj analogue of NVL2() function in Oracle SQLstatic <T,
R> R notNullReplaceElseLazy
(T obj, Supplier<? extends R> replaceSupplier, Supplier<? extends R> defaultSupplier)
-
Constructor Details
-
Objs
public Objs()
-
-
Method Details
-
decode
public static <OUT,IN> OUT decode(IN obj, IN compare, OUT then, OUT orElse) -
isNull
-
isNotNull
-
equals
-
notNull
public static <T> T notNull(T obj) Throws NullPointerException if object is null- Type Parameters:
T
-- Parameters:
obj
- Object that will be checked- Returns:
- passed object
-
notNull
Throws NullPointerException with provided message if object is null- Type Parameters:
T
-- Parameters:
obj
- Object that will be checkedmessage
- Message for exception- Returns:
- passed object
-
notNull
public static <X extends Throwable,T> T notNull(T obj, Supplier<? extends X> exceptionSupplier) throws X Throws custom exception if object is null- Type Parameters:
T
-- Parameters:
obj
- Object that will be checkedexceptionSupplier
- Exception provider that will be thrown if object is null- Returns:
- passed object
- Throws:
X
-
notNullDo
-
notNullElse
public static <T> T notNullElse(T obj, T defaultObj) Replaces importing of Objects.requireNonNullElse() Returns defaultObj if obj is null -
notNullElseLazy
-
notNullReplaceElse
public static <T,R> R notNullReplaceElse(T obj, R replaceObj, R defaultObj) If not null returns replaceObj, if null returns defaultObj analogue of NVL2() function in Oracle SQL -
notNullReplaceElseLazy
-