top.lingkang.finalsql.utils.CommonUtils Maven / Gradle / Ivy
package top.lingkang.finalsql.utils;
import top.lingkang.finalsql.error.FinalException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
/**
* @author lingkang
* Created by 2022/5/3
*/
public class CommonUtils {
public static boolean isEmpty(CharSequence cs) {
return cs == null || cs.length() == 0;
}
public static boolean isNull(Object obj) {
return obj == null;
}
public static boolean notEmpty(Object... args) {
return args != null && args.length != 0;
}
public static boolean isEmpty(Collection> collection) {
return collection == null || collection.isEmpty();
}
public static boolean isNotEmpty(CharSequence cs) {
return !isEmpty(cs);
}
public static void close(AutoCloseable closeable) {
if (closeable != null) {
try {
closeable.close();
} catch (Exception e) {
// 不做处理
}
}
}
public static int getFindNumber(String str, String findStr) {
int index = 0;
int has = 0;
while ((index = str.indexOf(findStr, index)) != -1) {
has++;
index++;
}
return has;
}
public static void checkParam(String sql, List