Package io.rocketbase.commons.util
Class Nulls
java.lang.Object
io.rocketbase.commons.util.Nulls
shorten null checks
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> voidaccept when value is not nullstatic <T> booleananyNoneNullValue(T... values) return's true if at least one of the values it not nullstatic <T,R> R apply when value is not nullstatic <T> booleannoneNullValue(T... values) return's true if all values are not null
false in case one is nullstatic Stringreturns fallback when value is emptystatic <SOURCE> StringnotEmpty(SOURCE value, Nulls.PropertyValueProvider<SOURCE, String> provider, String fallback) static Booleanreturn false when value is nullstatic Integerreturn 0 when value is nullstatic Longreturn 0 when value is nullstatic Stringreturns empty string when value is nullstatic BigDecimalnotNull(BigDecimal value) return BigDecimal.ZERO when value is nullstatic <T> List<T>in case of null value return's new ArrayListstatic <K,V> Map<K, V> in case of null value return's new HashMap<K,Vstatic <T> Set<T>in case of null value return's new HashSetstatic <SOURCE> StringnotNull(SOURCE value, Nulls.PropertyValueProvider<SOURCE, String> provider) static <TARGET,SOURCE>
TARGETnotNull(SOURCE value, Nulls.PropertyValueProvider<SOURCE, TARGET> provider, TARGET fallback) static <T> TnotNull(T value, T fallback) when value is null returns fallback
-
Constructor Details
-
Nulls
public Nulls()
-
-
Method Details
-
notNull
public static <T> T notNull(T value, T fallback) when value is null returns fallback -
notNull
returns empty string when value is null -
notNull
return false when value is null -
notNull
return 0 when value is null -
notNull
return 0 when value is null -
notNull
return BigDecimal.ZERO when value is null -
notNull
in case of null value return's new ArrayList -
notNull
in case of null value return's new HashSet -
notNull
in case of null value return's new HashMap<K,V -
accept
accept when value is not null -
apply
apply when value is not null -
notEmpty
returns fallback when value is empty -
notNull
public static <TARGET,SOURCE> TARGET notNull(SOURCE value, Nulls.PropertyValueProvider<SOURCE, TARGET> provider, TARGET fallback) -
notNull
public static <SOURCE> String notNull(SOURCE value, Nulls.PropertyValueProvider<SOURCE, String> provider) -
notEmpty
public static <SOURCE> String notEmpty(SOURCE value, Nulls.PropertyValueProvider<SOURCE, String> provider, String fallback) -
noneNullValue
public static <T> boolean noneNullValue(T... values) return's true if all values are not null
false in case one is null -
anyNoneNullValue
public static <T> boolean anyNoneNullValue(T... values) return's true if at least one of the values it not null
-