private static final char[] CHARS = "elzx2NTYU8LZrtyG4uiopIOPHJQsdfghjkXCVBcvbWER7anm_F56-01MqwK3ASD9".toCharArray(); public static final String PHONE_BLUR_REGEX = "(\d{3})\d{4}(\d{4})"; public static final String PHONE_BLUR_REPLACE_REGEX = "2";
public CommonUtil() {
}
public static String blankStr() {
return "";
}
public static boolean isEmpty(Collection<?> collection) {
return collection == null || collection.isEmpty();
}
public static boolean isEmpty(Map<?, ?> map) {
return map == null || map.isEmpty();
}
public static boolean isBlank(String str) {
return Objects.isNull(str) || Objects.equals(blankStr(), str.trim());
}
public static boolean isNotEmpty(Collection<?> collection) {
return !isEmpty(collection);
}
public static boolean isNotEmpty(Map<?, ?> map) {
return !isEmpty(map);
}
public static boolean isNotBlank(String str) {
return Objects.nonNull(str) && !Objects.equals(blankStr(), str.trim());
}
public static boolean gtZero(Integer value) {
return Objects.nonNull(value) && value > 0;
}
public static boolean notNullTrue(Boolean value) {
return Objects.nonNull(value) && value;
}
public static boolean notNullFalse(Boolean value) {
return Objects.nonNull(value) && !value;
}
public static boolean gtZero(Long value) {
return Objects.nonNull(value) && value > 0L;
}
public static boolean nullOrLeZero(Integer value) {
return Objects.isNull(value) || value <= 0;
}
public static boolean nullOrLeZero(Long value) {
return Objects.isNull(value) || value <= 0L;
}
public static <T> boolean nullOrEq(T value, T or) {
return value == null || value == or || value.equals(or);
}
public static <T> boolean notNullAndEq(T value, T or) {
return value != null && (value == or || value.equals(or));
}
public static <K, V, R> List<R> mapConvertList(Map<K, V> source, Function<Map.Entry<K, V>, R> getValue) {
if (isEmpty(source)) {
return new ArrayList();
} else {
List<R> rList = new ArrayList(source.size());
Iterator var3 = source.entrySet().iterator();
while(var3.hasNext()) {
Map.Entry<K, V> e = (Map.Entry)var3.next();
rList.add(getValue.apply(e));
}
return rList;
}
}
public static <K, V, R> Map<K, V> listConvertMap(List<R> list, Predicate<R> predicate, Function<R, K> getKey, Function<R, V> getValue) {
if (isEmpty((Collection)list)) {
return new HashMap(8);
} else {
Map<K, V> map = new HashMap(Math.min(list.size(), 256));
Iterator var5 = list.iterator();
while(var5.hasNext()) {
R r = var5.next();
if (predicate.test(r)) {
map.put(getKey.apply(r), getValue.apply(r));
}
}
return map;
}
}
public static <K, V, T> Map<K, V> listConvertMap(List<T> list, Function<T, K> getKey, Function<T, V> getValue) {
return listConvertMap(list, (t) -> {
return true;
}, getKey, getValue);
}
public static <K, V> Map<K, V> listConvertMap(List<V> list, Function<V, K> getKey) {
return listConvertMap(list, (t) -> {
return true;
}, getKey, Function.identity());
}
public static <R, E> List<R> listConvert(List<E> sourceList, Function<E, R> getValue) {
if (isEmpty((Collection)sourceList)) {
return new ArrayList();
} else {
List<R> rList = new ArrayList(sourceList.size());
Iterator var3 = sourceList.iterator();
while(var3.hasNext()) {
E e = var3.next();
rList.add(getValue.apply(e));
}
return rList;
}
}
public static <R, E> List<R> listConvert(List<E> sourceList, Predicate<E> predicate, Function<E, R> getValue) {
if (isEmpty((Collection)sourceList)) {
return new ArrayList();
} else {
List<R> rList = new ArrayList(sourceList.size());
Iterator var4 = sourceList.iterator();
while(var4.hasNext()) {
E item = var4.next();
if (predicate.test(item)) {
rList.add(getValue.apply(item));
}
}
return rList;
}
}
public static <K, V, R> Map<K, List<R>> listConvertListMap(List<V> list, Function<V, K> getKey, Function<V, R> getValue) {
if (list != null && !list.isEmpty()) {
Map<K, List<R>> map = new HashMap(Math.min(list.size(), 256));
Iterator var5 = list.iterator();
while(var5.hasNext()) {
V v = var5.next();
K key = getKey.apply(v);