java.lang.Object
tech.deplant.java4ever.utils.Objs
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanstatic booleanstatic booleanstatic <T> TnotNull(T obj) Throws NullPointerException if object is nullstatic <T> TThrows NullPointerException with provided message if object is nullstatic <X extends Throwable,T>
TThrows custom exception if object is nullstatic <T> voidstatic <T> TnotNullElse(T obj, T defaultObj) Replaces importing of Objects.requireNonNullElse() Returns defaultObj if obj is nullstatic <T> TnotNullElseLazy(T obj, Supplier<? extends T> supplier) static <T> TnotNullReplaceElse(T obj, T replaceObj, T defaultObj) If not null returns replaceObj, if null returns defaultObj analogue of NVL2() function in Oracle SQLstatic <T> TnotNullReplaceElseLazy(T obj, Supplier<? extends T> replaceSupplier, Supplier<? extends T> defaultSupplier)
-
Constructor Details
-
Objs
public Objs()
-
-
Method Details
-
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 extends Throwable
-
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> T notNullReplaceElse(T obj, T replaceObj, T defaultObj) If not null returns replaceObj, if null returns defaultObj analogue of NVL2() function in Oracle SQL -
notNullReplaceElseLazy
-