Class Nulls
- java.lang.Object
-
- com.sportradar.livedata.sdk.common.classes.Nulls
-
public final class Nulls extends Object
Basically this is versions of 2 methods: etn (empty to null) and nte (null to empty). If you are calling Nulls.nte(), compiler will find needed version itself by collection you had passed. For example: Nulls.nte(new List()) will call public static <T> List<T> nte(final List<T> list).
As a result, code: if(list != null){ for(obj : list){} } will turn into: for(obj : Nulls.nte(list)){}
-
-
Field Summary
Fields Modifier and Type Field Description static byte[]
EMPTY_BYTES
static int[]
EMPTY_INTS
static long[]
EMPTY_LONGS
static Object[]
EMPTY_OBJECTS
static String[]
EMPTY_STRINGS
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> T
checkNotNull(T reference)
static <T> T
checkNotNull(T reference, Object errorMessage)
static <T> T
checkNotNull(T reference, String errorMessageTemplate, Object... errorMessageArgs)
static String
emptyToNull(String str)
static <T> List<T>
emptyToNull(List<T> list)
static <K,V>
Map<K,V>emptyToNull(Map<K,V> map)
static <T> Set<T>
emptyToNull(Set<T> set)
static String
etn(String str)
static <T> List<T>
etn(List<T> list)
static <K,V>
Map<K,V>etn(Map<K,V> map)
static <T> Set<T>
etn(Set<T> set)
static <T> T
firstNonNull(T first, T second)
static <T> T
firstNonNullIfExists(T... values)
static <T> boolean
hasNotNulls(T... objs)
static <T> boolean
hasNulls(T... objs)
static byte[]
nte(byte[] bytes)
static int[]
nte(int[] ints)
static long[]
nte(long[] longs)
static Object[]
nte(Object[] objects)
static String
nte(String str)
Convertnull
string to empty string.static String[]
nte(String[] strings)
static <T> Collection<T>
nte(Collection<T> collection)
static <T> List<T>
nte(List<T> list)
static <K,V>
Map<K,V>nte(Map<K,V> map)
static <T> Set<T>
nte(Set<T> set)
static byte[]
nullToEmpty(byte[] bytes)
static int[]
nullToEmpty(int[] ints)
static long[]
nullToEmpty(long[] longs)
static Object[]
nullToEmpty(Object[] objects)
static String
nullToEmpty(String str)
static String[]
nullToEmpty(String[] strings)
static <T> Collection<T>
nullToEmpty(Collection<T> collection)
static <T> List<T>
nullToEmpty(List<T> list)
static <K,V>
Map<K,V>nullToEmpty(Map<K,V> map)
static <T> Set<T>
nullToEmpty(Set<T> set)
static <T extends Number>
TnullToZero(T value)
-
-
-
Method Detail
-
nullToZero
public static <T extends Number> T nullToZero(T value)
-
nte
public static String nte(String str)
Convertnull
string to empty string. Non-null string returned as is.- Parameters:
str
- test value- Returns:
- empty or given value.
-
nte
public static byte[] nte(byte[] bytes)
-
nullToEmpty
public static byte[] nullToEmpty(byte[] bytes)
-
nte
public static int[] nte(int[] ints)
-
nullToEmpty
public static int[] nullToEmpty(int[] ints)
-
nte
public static long[] nte(long[] longs)
-
nullToEmpty
public static long[] nullToEmpty(long[] longs)
-
nte
public static <T> Collection<T> nte(Collection<T> collection)
-
nullToEmpty
public static <T> Collection<T> nullToEmpty(Collection<T> collection)
-
hasNulls
public static <T> boolean hasNulls(T... objs)
-
hasNotNulls
public static <T> boolean hasNotNulls(T... objs)
-
firstNonNullIfExists
public static <T> T firstNonNullIfExists(T... values)
-
firstNonNull
public static <T> T firstNonNull(T first, T second)
-
checkNotNull
public static <T> T checkNotNull(T reference)
-
checkNotNull
public static <T> T checkNotNull(T reference, @Nullable Object errorMessage)
-
-