Class Nulls
java.lang.Object
com.sportradar.livedata.sdk.common.classes.Nulls
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 -
Method Summary
Modifier and TypeMethodDescriptionstatic <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
static <T> List
<T> static <K,
V> Map <K, V> static <T> Set
<T> 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[]
static String
Convertnull
string to empty string.static String[]
static <T> Collection
<T> nte
(Collection<T> collection) static <T> List
<T> static <K,
V> Map <K, V> static <T> Set
<T> 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)
-
Field Details
-
EMPTY_STRINGS
-
EMPTY_OBJECTS
-
EMPTY_BYTES
public static final byte[] EMPTY_BYTES -
EMPTY_INTS
public static final int[] EMPTY_INTS -
EMPTY_LONGS
public static final long[] EMPTY_LONGS
-
-
Method Details
-
nullToZero
-
nte
Convertnull
string to empty string. Non-null string returned as is.- Parameters:
str
- test value- Returns:
- empty or given value.
-
nullToEmpty
-
nte
-
nullToEmpty
-
nte
-
nullToEmpty
-
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
-
nullToEmpty
-
nte
-
nullToEmpty
-
nte
-
nullToEmpty
-
nte
-
nullToEmpty
-
etn
-
emptyToNull
-
etn
-
emptyToNull
-
etn
-
emptyToNull
-
etn
-
emptyToNull
-
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
-
checkNotNull
-