public class CodeUtil
extends java.lang.Object
| Constructor and Description |
|---|
CodeUtil() |
| Modifier and Type | Method and Description |
|---|---|
static <T> void |
applyIfNotNull(T input,
java.util.function.Consumer<T> action)
Applied the Consumer on the input if the input is not null,
serves as a way to avoid writing:
if(input != null){
action.apply(input);
}
and replacing it with
applyIfNotNull(input,action);
|
static <T> T |
getOrElse(T value1,
T value2)
Mimic of Oracle's nvl() - returns the first value if not null, otherwise the second value.
|
public static <T> T getOrElse(T value1,
T value2)
public static <T> void applyIfNotNull(T input,
java.util.function.Consumer<T> action)
if(input != null){
action.apply(input);
}
and replacing it with
applyIfNotNull(input,action);
T - the type of the input.input - a nullable objectaction - a Consumer that will be applied to the input if it isn't null.