@LevelUpApi(contract=INTERNAL) public final class NullUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static String |
format(Locale locale,
String format,
Object... args)
A wrapper around
String.format(Locale, String, Object...) which returns a non-null
result and uses Locale.US. |
static String |
format(String format,
Object... args)
A wrapper around
String.format(Locale, String, Object...) which returns a non-null
result and uses Locale.US. |
static String |
getClassName(Class<?> clazz) |
static <T> T |
nonNullContract(T source)
Retrieves a non-null result from source or throws an exception if the source is null.
|
static <T> T |
nonNullContract(T source,
String what)
Retrieves a non-null result from source or throws an exception if the source is null.
|
public static <T> T nonNullContract(T source,
String what)
T - type of object to return.source - source object or null.what - a human-readable identifier for the item.AssertionError - if the source is nullpublic static <T> T nonNullContract(T source)
T - type of object to return.source - source object or null.AssertionError - if the source is nullpublic static String getClassName(Class<?> clazz)
clazz - the class whose name is being retrievedpublic static String format(String format, Object... args)
String.format(Locale, String, Object...) which returns a non-null
result and uses Locale.US.format - format stringargs - optional argumentspublic static String format(Locale locale, String format, Object... args)
String.format(Locale, String, Object...) which returns a non-null
result and uses Locale.US.locale - format localeformat - format stringargs - optional arguments