mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add methods
This commit is contained in:
@@ -53,7 +53,7 @@ public abstract class AbstractConverter<T> implements Converter<T>, Serializable
|
||||
if (null == defaultValue || targetType.isInstance(defaultValue)) {
|
||||
if (targetType.isInstance(value) && false == Map.class.isAssignableFrom(targetType)) {
|
||||
// 除Map外,已经是目标类型,不需要转换(Map类型涉及参数类型,需要单独转换)
|
||||
return (T) targetType.cast(value);
|
||||
return targetType.cast(value);
|
||||
}
|
||||
T result = convertInternal(value);
|
||||
return ((null == result) ? defaultValue : result);
|
||||
|
@@ -34,6 +34,7 @@ public class FastByteArrayOutputStream extends OutputStream {
|
||||
buffer = new FastByteBuffer(size);
|
||||
}
|
||||
|
||||
@SuppressWarnings("NullableProblems")
|
||||
@Override
|
||||
public void write(byte[] b, int off, int len) {
|
||||
buffer.append(b, off, len);
|
||||
@@ -52,7 +53,7 @@ public class FastByteArrayOutputStream extends OutputStream {
|
||||
* 此方法无任何效果,当流被关闭后不会抛出IOException
|
||||
*/
|
||||
@Override
|
||||
public void close() throws IOException{
|
||||
public void close() {
|
||||
// nop
|
||||
}
|
||||
|
||||
|
@@ -244,6 +244,7 @@ public class CharUtil {
|
||||
* @return true表示为字符类
|
||||
*/
|
||||
public static boolean isChar(Object value) {
|
||||
//noinspection ConstantConditions
|
||||
return value instanceof Character || value.getClass() == char.class;
|
||||
}
|
||||
|
||||
@@ -283,13 +284,14 @@ public class CharUtil {
|
||||
* @since 4.0.8
|
||||
*/
|
||||
public static boolean isEmoji(char c) {
|
||||
//noinspection ConstantConditions
|
||||
return false == ((c == 0x0) || //
|
||||
(c == 0x9) || //
|
||||
(c == 0xA) || //
|
||||
(c == 0xD) || //
|
||||
((c >= 0x20) && (c <= 0xD7FF)) || //
|
||||
((c >= 0xE000) && (c <= 0xFFFD)) || //
|
||||
((c >= 0x10000) && (c <= 0x10FFFF)));
|
||||
((c >= 0x100000) && (c <= 0x10FFFF)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -319,4 +321,14 @@ public class CharUtil {
|
||||
}
|
||||
return c1 == c2;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字符类型
|
||||
* @param c 字符
|
||||
* @return 字符类型
|
||||
* @since 5.2.3
|
||||
*/
|
||||
public static int getType(int c){
|
||||
return Character.getType(c);
|
||||
}
|
||||
}
|
||||
|
@@ -20,4 +20,10 @@ public class CharUtilTest {
|
||||
Assert.assertTrue(CharUtil.isEmoji(a.charAt(1)));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isCharTest(){
|
||||
char[] a = new char[]{'a'};
|
||||
Assert.assertTrue(CharUtil.isChar(a));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user