001package run.iget.framework.common.util;
002
003import java.util.Arrays;
004import java.util.Collection;
005import java.util.Map;
006import java.util.Objects;
007
008import cn.hutool.core.collection.CollectionUtil;
009import cn.hutool.core.util.StrUtil;
010
011public class CheckUtils {
012
013    public static boolean isBlank(String obj) {
014        return StrUtil.isBlank(obj);
015    }
016
017    public static boolean isNotBlank(String obj) {
018        return StrUtil.isNotBlank(obj);
019    }
020
021    public static boolean isTrue(Boolean obj) {
022        return Objects.equals(Boolean.TRUE, obj);
023    }
024
025    public static boolean isAnyTrue(Boolean... obj) {
026        if (Objects.isNull(obj)) {
027            return false;
028        }
029        return Arrays.stream(obj).anyMatch(item -> isTrue(item));
030    }
031
032    public static boolean isAnyNotTrue(Boolean... obj) {
033        if (Objects.isNull(obj)) {
034            return false;
035        }
036        return Arrays.stream(obj).anyMatch(item -> isNotTrue(item));
037    }
038
039    public static boolean isAllTrue(Boolean... obj) {
040        if (Objects.isNull(obj)) {
041            return false;
042        }
043        return Arrays.stream(obj).allMatch(item -> isTrue(item));
044    }
045
046    public static boolean isNotTrue(Object obj) {
047        return !Objects.equals(Boolean.TRUE, obj);
048    }
049
050    public static boolean isFalse(Boolean obj) {
051        return Objects.equals(Boolean.FALSE, obj);
052    }
053
054    public static boolean isNotFalse(Object obj) {
055        return !Objects.equals(Boolean.FALSE, obj);
056    }
057
058    public static boolean isNull(Object obj) {
059        return Objects.isNull(obj);
060    }
061
062    public static boolean isNotNull(Object obj) {
063        return Objects.nonNull(obj);
064    }
065
066    public static boolean isAnyNull(Object... obj) {
067        if (Objects.isNull(obj)) {
068            return true;
069        }
070        return Arrays.stream(obj).anyMatch(item -> isNull(item));
071    }
072
073    public static boolean isAnyNotNull(Object... obj) {
074        if (Objects.isNull(obj)) {
075            return false;
076        }
077        return Arrays.stream(obj).anyMatch(item -> isNotNull(item));
078    }
079
080    public static boolean isAllNull(Object... obj) {
081        if (Objects.isNull(obj)) {
082            return true;
083        }
084        return Arrays.stream(obj).allMatch(item -> isNull(item));
085    }
086
087    public static boolean isAllNotNull(Object... obj) {
088        if (Objects.isNull(obj)) {
089            return false;
090        }
091        return Arrays.stream(obj).allMatch(item -> isNotNull(item));
092    }
093
094    public static boolean isEmpty(Map obj) {
095        return CollectionUtil.isEmpty(obj);
096    }
097
098    public static boolean isNotEmpty(Map obj) {
099        return CollectionUtil.isNotEmpty(obj);
100    }
101
102    public static boolean isAnyEmpty(Map... obj) {
103        if (Objects.isNull(obj)) {
104            return true;
105        }
106        return Arrays.stream(obj).anyMatch(item -> isEmpty(item));
107    }
108
109    public static boolean isAnyNotEmpty(Map... obj) {
110        if (Objects.isNull(obj)) {
111            return false;
112        }
113        return Arrays.stream(obj).anyMatch(item -> isNotEmpty(item));
114    }
115
116    public static boolean isAllEmpty(Map... obj) {
117        if (Objects.isNull(obj)) {
118            return true;
119        }
120        return Arrays.stream(obj).allMatch(item -> isEmpty(item));
121    }
122
123    public static boolean isAllNotEmpty(Map... obj) {
124        if (Objects.isNull(obj)) {
125            return false;
126        }
127        return Arrays.stream(obj).allMatch(item -> isNotEmpty(item));
128    }
129
130    public static boolean isEmpty(Collection obj) {
131        return CollectionUtil.isEmpty(obj);
132    }
133
134    public static boolean isNotEmpty(Collection obj) {
135        return CollectionUtil.isNotEmpty(obj);
136    }
137
138    public static boolean isAnyEmpty(Collection... obj) {
139        if (Objects.isNull(obj)) {
140            return true;
141        }
142        return Arrays.stream(obj).anyMatch(item -> isEmpty(item));
143    }
144
145    public static boolean isAnyNotEmpty(Collection... obj) {
146        if (Objects.isNull(obj)) {
147            return false;
148        }
149        return Arrays.stream(obj).anyMatch(item -> isNotEmpty(item));
150    }
151
152    public static boolean isAllEmpty(Collection... obj) {
153        if (Objects.isNull(obj)) {
154            return true;
155        }
156        return Arrays.stream(obj).allMatch(item -> isEmpty(item));
157    }
158
159    public static boolean isAllNotEmpty(Collection... obj) {
160        if (Objects.isNull(obj)) {
161            return false;
162        }
163        return Arrays.stream(obj).allMatch(item -> isNotEmpty(item));
164    }
165
166}