Java Utililty Methods Object NVL

List of utility methods to do Object NVL

Description

The list of methods to do Object NVL are organized into topic(s).

Method

Stringnvl(String x, String y)
nvl
if (x == null || x.length() == 0)
    return y;
else
    return x;
Tnvl(T mainValue, T... fallbackValues)
Allows a list of values to be provided, the first non-null value in the list is returned as the result.
T result = mainValue;
int idx = 0;
while (result == null && idx < fallbackValues.length) {
    result = fallbackValues[idx++];
return result;
Tnvl(T o, T replacement)
Returns the passed object, if not null, or replacement otherwise
return (isNull(o) ? replacement : o);
Tnvl(T o, T valueIfNull)
nvl
if (isEmpty(o)) {
    return valueIfNull;
return o;
Tnvl(T object, T defaultValue)
plsql has one or two useful functions and this is one of them.
return object != null ? object : defaultValue;
Tnvl(T s, T def)
nvl
return s != null ? s : def;
Tnvl(T t, String message)
Tests the passed object for nullness.
if (t == null)
    throw new IllegalArgumentException(message != null ? message : "Null parameter");
return t;
Tnvl(T t, String message)
nvl
if (t == null)
    throw new IllegalArgumentException(message);
return (T) t;
Stringnvl(T value, String defValue)
nvl
return ((value != null) ? String.valueOf(value) : defValue);
Tnvl(T value, T defaultValue)
Returns the default value if the value is null.
return value != null ? value : defaultValue;