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

booleanisEmpty(Object obj)
Like the Groovy empty except doesn't consider empty 0 value numbers, false Boolean, etc; only null values, 0 length String (actually CharSequence to include GString, etc), and 0 size Collection/Map are considered empty.
if (obj == null)
    return true;
if (obj instanceof CharSequence)
    return ((CharSequence) obj).length() == 0;
if (obj instanceof Collection)
    return ((Collection) obj).size() == 0;
return obj instanceof Map && ((Map) obj).size() == 0;
booleanisEmpty(Object value)
Check that value wasn't set by json parser.
return (null == value) || (value.getClass().equals(Boolean.class) && !((Boolean) value))
        || (value.getClass().equals(Integer.class) && (Integer) value == 0)
        || (value.getClass().equals(Long.class) && (Long) value == 0)
        || (Collection.class.isAssignableFrom(value.getClass()) && ((Collection) value).isEmpty())
        || (Map.class.isAssignableFrom(value.getClass()) && ((Map) value).isEmpty())
        || (value.getClass().equals(Byte.class) && (Byte) value == 0)
        || (value.getClass().equals(Short.class) && (Short) value == 0)
        || (value.getClass().equals(Double.class) && (Double) value == 0)
...
booleanisEmpty(Object... obj)
is Empty
return obj == null || obj.length == 0 ? true : false;
booleanisNotEmpty(Object object)
is Not Empty
return isTrue(object);
booleanisNullOrEmpty(final Object obj)
is Null Or Empty
if (obj == null) {
    return true;
if (obj.getClass().equals(Collection.class)) {
    return ((Collection) obj).size() == 0;
} else {
    if (obj.toString().trim().length() == 0) {
        return true;
...
booleanisNullOrEmpty(Object object, boolean zeroEqualsEmpty)
is Null Or Empty
if (object == null)
    return true;
if (object instanceof Collection)
    return ((Collection) object).size() == 0;
else if (object instanceof Map)
    return ((Map) object).size() == 0;
else if (object.getClass().isArray())
    return ((Object[]) object).length == 0;
...
booleanisNullOrEmptyOrZero(Object object)
Returns true if the object specified is null or empty (e.g., an empty string, or an empty collection, or in this case a zero-valued number)
return (isNullOrEmpty(object, true));
booleannvl(Boolean b, boolean defaultValue)
nvl
if (b == null) {
    return defaultValue;
return b.booleanValue();
Stringnvl(CharSequence source)
nvl
return nvl(source, "");
Envl(E expr1, E expr2)
Nvl function.
return (null != expr1) ? expr1 : expr2;