List of utility methods to do Object NVL
boolean | isEmpty(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; |
boolean | isEmpty(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) ... |
boolean | isEmpty(Object... obj) is Empty return obj == null || obj.length == 0 ? true : false;
|
boolean | isNotEmpty(Object object) is Not Empty return isTrue(object);
|
boolean | isNullOrEmpty(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; ... |
boolean | isNullOrEmpty(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; ... |
boolean | isNullOrEmptyOrZero(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));
|
boolean | nvl(Boolean b, boolean defaultValue) nvl if (b == null) { return defaultValue; return b.booleanValue(); |
String | nvl(CharSequence source) nvl return nvl(source, ""); |
E | nvl(E expr1, E expr2) Nvl function. return (null != expr1) ? expr1 : expr2;
|