mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix bug
This commit is contained in:
parent
f63acc6058
commit
97381d8168
@ -43,7 +43,8 @@ public interface Table<R, C, V> extends Iterable<Table.Cell<R, C, V>> {
|
|||||||
* @return 是否包含映射
|
* @return 是否包含映射
|
||||||
*/
|
*/
|
||||||
default boolean contains(final R rowKey, final C columnKey) {
|
default boolean contains(final R rowKey, final 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
|
||||||
|
@ -34,6 +34,16 @@ public class RowKeyTableTest {
|
|||||||
// 获取列
|
// 获取列
|
||||||
final Map<Integer, Integer> column = table.getColumn(6);
|
final Map<Integer, Integer> column = table.getColumn(6);
|
||||||
Assertions.assertEquals(1, column.size());
|
Assertions.assertEquals(1, column.size());
|
||||||
Assertions.assertEquals(new Integer(4), column.get(1));
|
Assertions.assertEquals(Integer.valueOf(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);
|
||||||
|
|
||||||
|
Assertions.assertNull(table.getRow(2));
|
||||||
|
Assertions.assertFalse(table.contains(2, 3));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user