Added missing handling of arrays in isEmpty function.
This commit is contained in:
parent
770e8bbe32
commit
bd1bb168da
2 changed files with 4 additions and 0 deletions
|
|
@ -58,6 +58,8 @@ public class ObjectUtil {
|
|||
return ((Map) obj).isEmpty();
|
||||
else if (obj instanceof List)
|
||||
return ((List) obj).isEmpty();
|
||||
else if (obj.getClass().isArray())
|
||||
return ((Object[]) obj).length == 0;
|
||||
else if (obj instanceof CharSequence)
|
||||
return ((CharSequence) obj).length() == 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ public class ObjectUtilTest {
|
|||
assertTrue(ObjectUtil.isEmpty(new LinkedList<>(), ""));
|
||||
assertTrue(ObjectUtil.isEmpty(new HashMap<>(), ""));
|
||||
assertTrue(ObjectUtil.isEmpty(new Hashtable<>(), ""));
|
||||
assertTrue(ObjectUtil.isEmpty((Object) new String[0]));
|
||||
|
||||
|
||||
assertFalse(ObjectUtil.isEmpty(" ", ""));
|
||||
|
|
@ -50,6 +51,7 @@ public class ObjectUtilTest {
|
|||
assertFalse(ObjectUtil.isEmpty("", new StringBuilder("a")));
|
||||
assertFalse(ObjectUtil.isEmpty("", new StringBuffer("a")));
|
||||
assertFalse(ObjectUtil.isEmpty("", Arrays.asList(1, 2, 3)));
|
||||
assertFalse(ObjectUtil.isEmpty((Object) new String[]{"a"}));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue