public abstract class ObjectUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T extends CharSequence> |
getNonEmptyOrDefault(T instance,
T defaultValue)
Returns the given instance, if not
null or of zero length, or otherwise the given defaultValue. |
static <T> T |
getOrDefault(T instance,
Supplier<T> defaultProvider)
Returns the given instance, if not
null, or otherwise the value provided by defaultProvider. |
static <T> T |
getOrDefault(T instance,
T defaultValue)
Returns the given instance, if not
null, or otherwise the given defaultValue. |
static long |
getRemainingOfDeadline(long deadline)
Gets number of millis which are remaining of current deadline to be reached by
System.currentTimeMillis(). |
static <T> Class<T> |
nullSafeTypeOf(T instance) |
public static <T> T getOrDefault(T instance,
Supplier<T> defaultProvider)
null, or otherwise the value provided by defaultProvider.T - The type of value to returninstance - The value to return, if not nulldefaultProvider - To provide the value, when instance is nullinstance if not null, otherwise the value provided by defaultProviderpublic static <T> T getOrDefault(T instance,
T defaultValue)
null, or otherwise the given defaultValue.T - The type of value to returninstance - The value to return, if not nulldefaultValue - The value, when instance is nullinstance if not null, otherwise defaultValuepublic static <T extends CharSequence> T getNonEmptyOrDefault(T instance, T defaultValue)
null or of zero length, or otherwise the given defaultValue.T - The type of value to returninstance - The value to return, if not nulldefaultValue - The value, when instance is nullinstance if not null, otherwise defaultValuepublic static <T> Class<T> nullSafeTypeOf(T instance)
public static long getRemainingOfDeadline(long deadline)
System.currentTimeMillis(). If deadline is passed, 0 will be returned.deadline - deadline to be metCopyright © 2010–2018. All rights reserved.