mirror of https://github.com/longtai-cn/hippo4j
服务端尝试更新一个不存在的线程池实例时, 通过抛异常处理. (#30)
parent
7c1c29fa10
commit
a631c676c7
@ -0,0 +1,40 @@
|
|||||||
|
package cn.hippo4j.common.toolkit;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collection util.
|
||||||
|
*
|
||||||
|
* @author chen.ma
|
||||||
|
* @date 2021/12/22 20:43
|
||||||
|
*/
|
||||||
|
public class CollectionUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get first.
|
||||||
|
*
|
||||||
|
* @param iterable
|
||||||
|
* @param <T>
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static <T> T getFirst(Iterable<T> iterable) {
|
||||||
|
Iterator<T> iterator;
|
||||||
|
if (iterable != null && (iterator = iterable.iterator()) != null && iterator.hasNext()) {
|
||||||
|
return iterator.next();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is not empty.
|
||||||
|
*
|
||||||
|
* @param map
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean isNotEmpty(Map<?, ?> map) {
|
||||||
|
return map != null && map.isEmpty() == false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
package cn.hippo4j.common.toolkit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* String util.
|
||||||
|
*
|
||||||
|
* @author chen.ma
|
||||||
|
* @date 2021/12/22 20:58
|
||||||
|
*/
|
||||||
|
public class StringUtil {
|
||||||
|
|
||||||
|
public static final String EMPTY = "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is blank.
|
||||||
|
*
|
||||||
|
* @param str
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean isBlank(String str) {
|
||||||
|
int length;
|
||||||
|
|
||||||
|
if ((str == null) || ((length = str.length()) == 0)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
char c = str.charAt(i);
|
||||||
|
|
||||||
|
boolean charNotBlank = Character.isWhitespace(c) || Character.isSpaceChar(c) || c == '\ufeff' || c == '\u202a';
|
||||||
|
if (charNotBlank == false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is not blank.
|
||||||
|
*
|
||||||
|
* @param str
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean isNotBlank(String str) {
|
||||||
|
return isBlank(str) == false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in new issue