mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
Merge pull request #2603 from youtiaoguagua/v5-dev
fix(bug): change ObjectUtil.defaultIfXXX param type Supplier to Function
This commit is contained in:
@@ -15,15 +15,15 @@ import java.util.Map;
|
||||
public class ObjectUtilTest {
|
||||
|
||||
@Test
|
||||
public void equalsTest(){
|
||||
public void equalsTest() {
|
||||
Object a = null;
|
||||
Object b = null;
|
||||
Assert.assertTrue(ObjectUtil.equals(a, b));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lengthTest(){
|
||||
int[] array = new int[]{1,2,3,4,5};
|
||||
public void lengthTest() {
|
||||
int[] array = new int[]{1, 2, 3, 4, 5};
|
||||
int length = ObjectUtil.length(array);
|
||||
Assert.assertEquals(5, length);
|
||||
|
||||
@@ -36,8 +36,8 @@ public class ObjectUtilTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void containsTest(){
|
||||
int[] array = new int[]{1,2,3,4,5};
|
||||
public void containsTest() {
|
||||
int[] array = new int[]{1, 2, 3, 4, 5};
|
||||
|
||||
final boolean contains = ObjectUtil.contains(array, 1);
|
||||
Assert.assertTrue(contains);
|
||||
@@ -73,6 +73,14 @@ public class ObjectUtilTest {
|
||||
Instant result2 = ObjectUtil.defaultIfNull(nullValue,
|
||||
() -> DateUtil.parse(nullValue, DatePattern.NORM_DATETIME_PATTERN).toInstant(), Instant.now());
|
||||
Assert.assertNotNull(result2);
|
||||
|
||||
Obj obj = new Obj();
|
||||
Obj objNull = null;
|
||||
String result3 = ObjectUtil.defaultIfNull(obj, (a) -> obj.doSomeThing(), "fail");
|
||||
Assert.assertNotNull(result3);
|
||||
|
||||
String result4 = ObjectUtil.defaultIfNull(objNull, Obj::doSomeThing, "fail");
|
||||
Assert.assertNotNull(result4);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -88,14 +96,14 @@ public class ObjectUtilTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isBasicTypeTest(){
|
||||
public void isBasicTypeTest() {
|
||||
int a = 1;
|
||||
final boolean basicType = ObjectUtil.isBasicType(a);
|
||||
Assert.assertTrue(basicType);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isNotNullTest(){
|
||||
public void isNotNullTest() {
|
||||
String a = null;
|
||||
Assert.assertFalse(ObjectUtil.isNotNull(a));
|
||||
}
|
||||
|
Reference in New Issue
Block a user