From e05a3b19e0faa3f048eaf217948a8b7be2dd0586 Mon Sep 17 00:00:00 2001 From: Looly Date: Thu, 5 May 2022 11:16:39 +0800 Subject: [PATCH] add methods --- CHANGELOG.md | 1 + .../java/cn/hutool/core/util/ObjectUtil.java | 16 ++++++++-------- .../java/cn/hutool/poi/excel/cell/CellUtil.java | 13 ++++++++----- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e0fd1c54..61c13f66d 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ * 【core 】 Singleton增加部分方法(pr#609@Gitee) * 【core 】 BeanUtil增加beanToMap重载(pr#2292@Github) * 【core 】 Assert增加对应的equals及notEquals方法(pr#612@Gitee) +* 【core 】 Assert增加对应的equals及notEquals方法(pr#612@Gitee) ### 🐞Bug修复 * 【db 】 修复RedisDS无法设置maxWaitMillis问题(issue#I54TZ9@Gitee) diff --git a/hutool-core/src/main/java/cn/hutool/core/util/ObjectUtil.java b/hutool-core/src/main/java/cn/hutool/core/util/ObjectUtil.java index 8fe082b43..00c3454de 100644 --- a/hutool-core/src/main/java/cn/hutool/core/util/ObjectUtil.java +++ b/hutool-core/src/main/java/cn/hutool/core/util/ObjectUtil.java @@ -104,7 +104,7 @@ public class ObjectUtil { int count; if (obj instanceof Iterator) { - Iterator iter = (Iterator) obj; + final Iterator iter = (Iterator) obj; count = 0; while (iter.hasNext()) { count++; @@ -113,7 +113,7 @@ public class ObjectUtil { return count; } if (obj instanceof Enumeration) { - Enumeration enumeration = (Enumeration) obj; + final Enumeration enumeration = (Enumeration) obj; count = 0; while (enumeration.hasMoreElements()) { count++; @@ -161,9 +161,9 @@ public class ObjectUtil { } if (obj instanceof Iterator) { - Iterator iter = (Iterator) obj; + final Iterator iter = (Iterator) obj; while (iter.hasNext()) { - Object o = iter.next(); + final Object o = iter.next(); if (equal(o, element)) { return true; } @@ -171,9 +171,9 @@ public class ObjectUtil { return false; } if (obj instanceof Enumeration) { - Enumeration enumeration = (Enumeration) obj; + final Enumeration enumeration = (Enumeration) obj; while (enumeration.hasMoreElements()) { - Object o = enumeration.nextElement(); + final Object o = enumeration.nextElement(); if (equal(o, element)) { return true; } @@ -181,9 +181,9 @@ public class ObjectUtil { return false; } if (obj.getClass().isArray() == true) { - int len = Array.getLength(obj); + final int len = Array.getLength(obj); for (int i = 0; i < len; i++) { - Object o = Array.get(obj, i); + final Object o = Array.get(obj, i); if (equal(o, element)) { return true; } diff --git a/hutool-poi/src/main/java/cn/hutool/poi/excel/cell/CellUtil.java b/hutool-poi/src/main/java/cn/hutool/poi/excel/cell/CellUtil.java index 1c7b59405..8c4f4d4cf 100644 --- a/hutool-poi/src/main/java/cn/hutool/poi/excel/cell/CellUtil.java +++ b/hutool-poi/src/main/java/cn/hutool/poi/excel/cell/CellUtil.java @@ -105,7 +105,7 @@ public class CellUtil { cellType = cell.getCellType(); } - Object value; + final Object value; switch (cellType) { case NUMERIC: value = new NumericCellValue(cell).getValue(); @@ -206,7 +206,7 @@ public class CellUtil { if (null == row) { return null; } - Cell cell = row.getCell(cellIndex); + final Cell cell = row.getCell(cellIndex); if (null == cell) { return new NullCell(row, cellIndex); } @@ -262,7 +262,7 @@ public class CellUtil { * @param sheet {@link Sheet} * @param x 列号,从0开始 * @param y 行号,从0开始 - * @return 是否是合并单元格 + * @return 是否是合并单元格,如果提供的sheet为{@code null},返回{@code false} */ public static boolean isMergedRegion(Sheet sheet, int x, int y) { if (sheet != null) { @@ -285,6 +285,7 @@ public class CellUtil { * @param sheet {@link Sheet} * @param locationRef 单元格地址标识符,例如A11,B5 * @return {@link CellRangeAddress} + * @since 5.8.0 */ public static CellRangeAddress getCellRangeAddress(Sheet sheet, String locationRef) { final CellLocation cellLocation = ExcelUtil.toLocation(locationRef); @@ -296,6 +297,7 @@ public class CellUtil { * * @param cell {@link Cell} * @return {@link CellRangeAddress} + * @since 5.8.0 */ public static CellRangeAddress getCellRangeAddress(Cell cell) { return getCellRangeAddress(cell.getSheet(), cell.getColumnIndex(), cell.getRowIndex()); @@ -308,6 +310,7 @@ public class CellUtil { * @param x 列号,从0开始 * @param y 行号,从0开始 * @return {@link CellRangeAddress} + * @since 5.8.0 */ public static CellRangeAddress getCellRangeAddress(Sheet sheet, int x, int y) { if (sheet != null) { @@ -331,7 +334,7 @@ public class CellUtil { * @param cellStyle {@link CellStyle} */ public static void setMergedRegionStyle(Cell cell, CellStyle cellStyle) { - CellRangeAddress cellRangeAddress = getCellRangeAddress(cell); + final CellRangeAddress cellRangeAddress = getCellRangeAddress(cell); if (cellRangeAddress != null) { setMergeCellStyle(cellStyle, cellRangeAddress, cell.getSheet()); } @@ -457,7 +460,7 @@ public class CellUtil { anchor.setRow1(cell.getRowIndex()); anchor.setRow2(cell.getRowIndex() + 2); } - Comment comment = drawing.createCellComment(anchor); + final Comment comment = drawing.createCellComment(anchor); comment.setString(factory.createRichTextString(commentText)); comment.setAuthor(StrUtil.nullToEmpty(commentAuthor)); cell.setCellComment(comment);