mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
将ObjUtil.defaultIfNull检验参数类型从Object改为泛型
This commit is contained in:
parent
c555a0cbab
commit
1361e11592
@ -13,7 +13,11 @@ import cn.hutool.core.text.StrUtil;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.Collection;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@ -305,8 +309,7 @@ public class ObjUtil {
|
||||
* @return 处理后的返回值
|
||||
* @since 6.0.0
|
||||
*/
|
||||
public static <T, R> R defaultIfNull(
|
||||
final T source, final Function<? super T, ? extends R> handler, final Supplier<? extends R> defaultSupplier) {
|
||||
public static <T, R> R defaultIfNull(final T source, final Function<? super T, ? extends R> handler, final Supplier<? extends R> defaultSupplier) {
|
||||
if (isNotNull(source)) {
|
||||
return handler.apply(source);
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ public class ObjUtilTest {
|
||||
public Obj clone() {
|
||||
try {
|
||||
return (Obj) super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
} catch (final CloneNotSupportedException e) {
|
||||
throw new CloneRuntimeException(e);
|
||||
}
|
||||
}
|
||||
@ -122,7 +122,7 @@ public class ObjUtilTest {
|
||||
|
||||
@Test
|
||||
public void cloneIfPossibleTest() {
|
||||
String a = "a";
|
||||
final String a = "a";
|
||||
final String a2 = ObjUtil.cloneIfPossible(a);
|
||||
Assert.assertNotSame(a, a2);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user