Last active
October 16, 2020 03:50
-
-
Save DeppWang/2683eadcb867470cdc1e3008d8fdf94c to your computer and use it in GitHub Desktop.
Java 工具类,判断空数据
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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