//验证为空 public static <T> boolean isEmpty(T obj){ return !isNotEmpty(obj); } //验证非空 public static <T> boolean isNotEmpty(T obj){ if(obj != null){ if(obj instanceof String){ //字符串 return String.valueOf(obj).trim().length() > 0; }else if(obj instanceof ArrayList){ //集合 return ((List) obj).size() > 0; }else if(obj instanceof HashMap){ //Map return !((Map) obj).isEmpty(); }else if(obj instanceof HashSet){ //Set return ((Set) obj).size() > 0; }else if(obj instanceof byte[]){ //byte[] return ((byte[]) obj).length > 0; }else if(obj instanceof short[]){ //short[] return ((short[]) obj).length > 0;