mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix code
This commit is contained in:
parent
095507a86d
commit
4f17d18e05
@ -1013,15 +1013,7 @@ public class MapUtil extends MapGetUtil {
|
||||
return map;
|
||||
}
|
||||
|
||||
final Iterator<Entry<K, V>> iter = map.entrySet().iterator();
|
||||
Entry<K, V> entry;
|
||||
while (iter.hasNext()) {
|
||||
entry = iter.next();
|
||||
if (null == entry.getValue()) {
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
|
||||
map.entrySet().removeIf(entry -> null == entry.getValue());
|
||||
return map;
|
||||
}
|
||||
|
||||
|
@ -285,4 +285,11 @@ public class MapUtilTest {
|
||||
final Map<String, Object> map = MapUtil.renameKey(v1, "name", "newName");
|
||||
Assertions.assertEquals("张三", map.get("newName"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void removeNullValueTest() {
|
||||
final Dict v1 = Dict.of().set("id", 12).set("name", null).set("age", null);
|
||||
final Map<String, Object> map = MapUtil.removeNullValue(v1);
|
||||
Assertions.assertEquals(1, map.size());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user