add methods

This commit is contained in:
Looly 2022-05-05 11:16:39 +08:00
parent c89b895618
commit e05a3b19e0
3 changed files with 17 additions and 13 deletions

View File

@ -13,6 +13,7 @@
* 【core 】 Singleton增加部分方法pr#609@Gitee * 【core 】 Singleton增加部分方法pr#609@Gitee
* 【core 】 BeanUtil增加beanToMap重载pr#2292@Github * 【core 】 BeanUtil增加beanToMap重载pr#2292@Github
* 【core 】 Assert增加对应的equals及notEquals方法pr#612@Gitee * 【core 】 Assert增加对应的equals及notEquals方法pr#612@Gitee
* 【core 】 Assert增加对应的equals及notEquals方法pr#612@Gitee
### 🐞Bug修复 ### 🐞Bug修复
* 【db 】 修复RedisDS无法设置maxWaitMillis问题issue#I54TZ9@Gitee * 【db 】 修复RedisDS无法设置maxWaitMillis问题issue#I54TZ9@Gitee

View File

@ -104,7 +104,7 @@ public class ObjectUtil {
int count; int count;
if (obj instanceof Iterator) { if (obj instanceof Iterator) {
Iterator<?> iter = (Iterator<?>) obj; final Iterator<?> iter = (Iterator<?>) obj;
count = 0; count = 0;
while (iter.hasNext()) { while (iter.hasNext()) {
count++; count++;
@ -113,7 +113,7 @@ public class ObjectUtil {
return count; return count;
} }
if (obj instanceof Enumeration) { if (obj instanceof Enumeration) {
Enumeration<?> enumeration = (Enumeration<?>) obj; final Enumeration<?> enumeration = (Enumeration<?>) obj;
count = 0; count = 0;
while (enumeration.hasMoreElements()) { while (enumeration.hasMoreElements()) {
count++; count++;
@ -161,9 +161,9 @@ public class ObjectUtil {
} }
if (obj instanceof Iterator) { if (obj instanceof Iterator) {
Iterator<?> iter = (Iterator<?>) obj; final Iterator<?> iter = (Iterator<?>) obj;
while (iter.hasNext()) { while (iter.hasNext()) {
Object o = iter.next(); final Object o = iter.next();
if (equal(o, element)) { if (equal(o, element)) {
return true; return true;
} }
@ -171,9 +171,9 @@ public class ObjectUtil {
return false; return false;
} }
if (obj instanceof Enumeration) { if (obj instanceof Enumeration) {
Enumeration<?> enumeration = (Enumeration<?>) obj; final Enumeration<?> enumeration = (Enumeration<?>) obj;
while (enumeration.hasMoreElements()) { while (enumeration.hasMoreElements()) {
Object o = enumeration.nextElement(); final Object o = enumeration.nextElement();
if (equal(o, element)) { if (equal(o, element)) {
return true; return true;
} }
@ -181,9 +181,9 @@ public class ObjectUtil {
return false; return false;
} }
if (obj.getClass().isArray() == true) { if (obj.getClass().isArray() == true) {
int len = Array.getLength(obj); final int len = Array.getLength(obj);
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
Object o = Array.get(obj, i); final Object o = Array.get(obj, i);
if (equal(o, element)) { if (equal(o, element)) {
return true; return true;
} }

View File

@ -105,7 +105,7 @@ public class CellUtil {
cellType = cell.getCellType(); cellType = cell.getCellType();
} }
Object value; final Object value;
switch (cellType) { switch (cellType) {
case NUMERIC: case NUMERIC:
value = new NumericCellValue(cell).getValue(); value = new NumericCellValue(cell).getValue();
@ -206,7 +206,7 @@ public class CellUtil {
if (null == row) { if (null == row) {
return null; return null;
} }
Cell cell = row.getCell(cellIndex); final Cell cell = row.getCell(cellIndex);
if (null == cell) { if (null == cell) {
return new NullCell(row, cellIndex); return new NullCell(row, cellIndex);
} }
@ -262,7 +262,7 @@ public class CellUtil {
* @param sheet {@link Sheet} * @param sheet {@link Sheet}
* @param x 列号从0开始 * @param x 列号从0开始
* @param y 行号从0开始 * @param y 行号从0开始
* @return 是否是合并单元格 * @return 是否是合并单元格如果提供的sheet为{@code null}返回{@code false}
*/ */
public static boolean isMergedRegion(Sheet sheet, int x, int y) { public static boolean isMergedRegion(Sheet sheet, int x, int y) {
if (sheet != null) { if (sheet != null) {
@ -285,6 +285,7 @@ public class CellUtil {
* @param sheet {@link Sheet} * @param sheet {@link Sheet}
* @param locationRef 单元格地址标识符例如A11B5 * @param locationRef 单元格地址标识符例如A11B5
* @return {@link CellRangeAddress} * @return {@link CellRangeAddress}
* @since 5.8.0
*/ */
public static CellRangeAddress getCellRangeAddress(Sheet sheet, String locationRef) { public static CellRangeAddress getCellRangeAddress(Sheet sheet, String locationRef) {
final CellLocation cellLocation = ExcelUtil.toLocation(locationRef); final CellLocation cellLocation = ExcelUtil.toLocation(locationRef);
@ -296,6 +297,7 @@ public class CellUtil {
* *
* @param cell {@link Cell} * @param cell {@link Cell}
* @return {@link CellRangeAddress} * @return {@link CellRangeAddress}
* @since 5.8.0
*/ */
public static CellRangeAddress getCellRangeAddress(Cell cell) { public static CellRangeAddress getCellRangeAddress(Cell cell) {
return getCellRangeAddress(cell.getSheet(), cell.getColumnIndex(), cell.getRowIndex()); return getCellRangeAddress(cell.getSheet(), cell.getColumnIndex(), cell.getRowIndex());
@ -308,6 +310,7 @@ public class CellUtil {
* @param x 列号从0开始 * @param x 列号从0开始
* @param y 行号从0开始 * @param y 行号从0开始
* @return {@link CellRangeAddress} * @return {@link CellRangeAddress}
* @since 5.8.0
*/ */
public static CellRangeAddress getCellRangeAddress(Sheet sheet, int x, int y) { public static CellRangeAddress getCellRangeAddress(Sheet sheet, int x, int y) {
if (sheet != null) { if (sheet != null) {
@ -331,7 +334,7 @@ public class CellUtil {
* @param cellStyle {@link CellStyle} * @param cellStyle {@link CellStyle}
*/ */
public static void setMergedRegionStyle(Cell cell, CellStyle cellStyle) { public static void setMergedRegionStyle(Cell cell, CellStyle cellStyle) {
CellRangeAddress cellRangeAddress = getCellRangeAddress(cell); final CellRangeAddress cellRangeAddress = getCellRangeAddress(cell);
if (cellRangeAddress != null) { if (cellRangeAddress != null) {
setMergeCellStyle(cellStyle, cellRangeAddress, cell.getSheet()); setMergeCellStyle(cellStyle, cellRangeAddress, cell.getSheet());
} }
@ -457,7 +460,7 @@ public class CellUtil {
anchor.setRow1(cell.getRowIndex()); anchor.setRow1(cell.getRowIndex());
anchor.setRow2(cell.getRowIndex() + 2); anchor.setRow2(cell.getRowIndex() + 2);
} }
Comment comment = drawing.createCellComment(anchor); final Comment comment = drawing.createCellComment(anchor);
comment.setString(factory.createRichTextString(commentText)); comment.setString(factory.createRichTextString(commentText));
comment.setAuthor(StrUtil.nullToEmpty(commentAuthor)); comment.setAuthor(StrUtil.nullToEmpty(commentAuthor));
cell.setCellComment(comment); cell.setCellComment(comment);