Here you can find the source of isNullOrEmptyOrZero(Object object)
Parameter | Description |
---|---|
object | the object to check |
public final static boolean isNullOrEmptyOrZero(Object object)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { /**//from w ww . ja va2 s . co m * 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) * * @param object the object to check * @return true if the text specified is null or empty, false otherwise */ public final static boolean isNullOrEmptyOrZero(Object object) { return (isNullOrEmpty(object, true)); } /** * Returns true if the object specified is null or empty (e.g., an empty * string, or an empty collection) * * @param object the object to check * @return true if the text specified is null or empty, false otherwise */ public final static boolean isNullOrEmpty(Object object) { return (isNullOrEmpty(object, false)); } private final static boolean isNullOrEmpty(Object object, boolean zeroEqualsEmpty) { 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; else if (object instanceof Number && zeroEqualsEmpty) return ((Number) object).longValue() == 0; else return object.toString().length() == 0; } }