mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
修复Table#contains空指针问题
This commit is contained in:
parent
37ca7779ca
commit
332fd5c346
@ -14,6 +14,7 @@
|
|||||||
* 【core 】 修复TreeUtil.getParentsName()获取到的路径集合中存在值为null的路径名称问题(issue#I795IN@Gitee)
|
* 【core 】 修复TreeUtil.getParentsName()获取到的路径集合中存在值为null的路径名称问题(issue#I795IN@Gitee)
|
||||||
* 【core 】 修复umberUtil.parseNumber对+解析问题(issue#I79VS7@Gitee)
|
* 【core 】 修复umberUtil.parseNumber对+解析问题(issue#I79VS7@Gitee)
|
||||||
* 【core 】 修复IdcardUtil.getGenderByIdCard存在潜在的异常(pr#1007@Gitee)
|
* 【core 】 修复IdcardUtil.getGenderByIdCard存在潜在的异常(pr#1007@Gitee)
|
||||||
|
* 【core 】 修复Table#contains空指针问题(issue#3135@Gitee)
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
# 5.8.19(2023-05-27)
|
# 5.8.19(2023-05-27)
|
||||||
|
@ -31,7 +31,8 @@ public interface Table<R, C, V> extends Iterable<Table.Cell<R, C, V>> {
|
|||||||
* @return 是否包含映射
|
* @return 是否包含映射
|
||||||
*/
|
*/
|
||||||
default boolean contains(R rowKey, C columnKey) {
|
default boolean contains(R rowKey, C columnKey) {
|
||||||
return Opt.ofNullable(getRow(rowKey)).map((map) -> map.containsKey(columnKey)).get();
|
return Opt.ofNullable(getRow(rowKey)).map((map) -> map.containsKey(columnKey))
|
||||||
|
.orElse(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
//region Row
|
//region Row
|
||||||
|
@ -36,4 +36,14 @@ public class RowKeyTableTest {
|
|||||||
Assert.assertEquals(1, column.size());
|
Assert.assertEquals(1, column.size());
|
||||||
Assert.assertEquals(new Integer(4), column.get(1));
|
Assert.assertEquals(new Integer(4), column.get(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void issue3135Test() {
|
||||||
|
final Table<Integer, Integer, Integer> table = new RowKeyTable<>();
|
||||||
|
table.put(1, 2, 3);
|
||||||
|
table.put(1, 6, 4);
|
||||||
|
|
||||||
|
Assert.assertNull(table.getRow(2));
|
||||||
|
Assert.assertFalse(table.contains(2, 3));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user