开发常用方法集锦(持续更新中)
1. 判断对象是否为空.
public static boolean empty(Object obj) { if (obj == null) return true; if ((obj instanceof String) && (((obj.equals("")) || (obj.equals("0"))))) return true; if ((obj instanceof Number) && (((Number)obj).doubleValue() == 0.0D)) return true; if ((obj instanceof Boolean) && (!((Boolean)obj).booleanValue())) return true; if ((obj instanceof Collection) && (((Collection)obj).isEmpty())) return true; if ((obj instanceof Map) && (((Map)obj).isEmpty())) { return true; } return (obj instanceof Object[]) && (((Object[])obj).length == 0); }