Skip to content

Instantly share code, notes, and snippets.

@DeppWang
Last active October 16, 2020 03:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DeppWang/2683eadcb867470cdc1e3008d8fdf94c to your computer and use it in GitHub Desktop.
Save DeppWang/2683eadcb867470cdc1e3008d8fdf94c to your computer and use it in GitHub Desktop.
Java 工具类,判断空数据
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
public class MatchUtil {
public MatchUtil() {
}
public static boolean isEmpty(Object obj) {
return obj == null;
}
public static boolean isEmpty(Map<?, ?> map) {
return map == null || map.size() == 0;
}
public static boolean isEmpty(String str) {
return str == null || "".equals(str) || "null".equalsIgnoreCase(str) || str.trim().length() == 0;
}
public static boolean isEmpty(Arrays[] arr) {
return arr == null || arr.length == 0;
}
public static boolean isEmpty(List<?> lis) {
return lis == null || lis.size() == 0;
}
public static boolean isEmpty(Iterator<?> ita) {
return ita == null || !ita.hasNext();
}
public static boolean isEmpty(StringBuffer sbf) {
return sbf == null || sbf.length() == 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment