Package io.rocketbase.commons.util
Class Nulls
- java.lang.Object
-
- io.rocketbase.commons.util.Nulls
-
public final class Nulls extends Object
shorten null checks
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceNulls.PropertyValueProvider<SOURCE,TARGET>
-
Constructor Summary
Constructors Constructor Description Nulls()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> voidaccept(T value, Consumer<T> consumer)accept when value is not nullstatic <T> booleananyNoneNullValue(T... values)return's true if at least one of the values it not nullstatic <T,R>
Rapply(T value, Function<T,R> function, R fallback)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 StringnotEmpty(String value, String fallback)returns fallback when value is emptystatic <SOURCE> StringnotEmpty(SOURCE value, Nulls.PropertyValueProvider<SOURCE,String> provider, String fallback)static BooleannotNull(Boolean value)return false when value is nullstatic LongnotNull(Long value)return 0 when value is nullstatic StringnotNull(String value)returns empty string when value is nullstatic BigDecimalnotNull(BigDecimal value)return BigDecimal.ZERO when value is nullstatic <T> List<T>notNull(List<T> value)in case of null value return's new ArrayListstatic <K,V>
Map<K,V>notNull(Map<K,V> value)in case of null value return's new HashMapstatic <T> Set<T>notNull(Set<T> value)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
-
-
-
Method Detail
-
notNull
public static <T> T notNull(T value, T fallback)when value is null returns fallback
-
notNull
public static BigDecimal notNull(BigDecimal value)
return BigDecimal.ZERO when value is null
-
notNull
public static <T> List<T> notNull(List<T> value)
in case of null value return's new ArrayList
-
notNull
public static <K,V> Map<K,V> notNull(Map<K,V> value)
in case of null value return's new HashMap-
accept
public static <T> void accept(T value, Consumer<T> consumer)accept when value is not null
-
apply
public static <T,R> R apply(T value, Function<T,R> function, R fallback)apply when value is not null
-
notEmpty
public static String notEmpty(String value, String fallback)
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
-
-
-