├── ObjectUtils.java └── README.md /ObjectUtils.java: -------------------------------------------------------------------------------- 1 | public class ObjectUtils { 2 | 3 | public static boolean isEmpty(Object s) { 4 | if (s == null) { 5 | return true; 6 | } 7 | if ((s instanceof String) && (((String)s).trim().length() == 0)) { 8 | return true; 9 | } 10 | if (s instanceof Map) { 11 | return ((Map)s).isEmpty(); 12 | } 13 | if (s instanceof List) { 14 | return ((List)s).isEmpty(); 15 | } 16 | if (s instanceof Object[]) { 17 | return (((Object[])s).length == 0); 18 | } 19 | return false; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # ObjectUtils 3 | when you want check object`(String, List, Map)`is empty or not, you can use this util 4 | 5 | ##How to use 6 | 7 | Use it as Util anywhere. Use it like this: 8 | 9 | ```javascript 10 | if(ObjectUtils.isEmpty(aa)){ 11 | // Object is empty. 12 | // do somthing 13 | } 14 | else{ 15 | // Object is not empty. 16 | // do somthing 17 | } 18 | ``` 19 | --------------------------------------------------------------------------------