diff --git a/src/main/java/cokr/xit/base/docs/xls/Format.java b/src/main/java/cokr/xit/base/docs/xls/Format.java index 828a4c3..b44ebed 100644 --- a/src/main/java/cokr/xit/base/docs/xls/Format.java +++ b/src/main/java/cokr/xit/base/docs/xls/Format.java @@ -64,8 +64,7 @@ public class Format implements Convert.Support { return convert.apply(obj); } - if (key != null && obj instanceof Map) { - Map map = (Map)obj; + if (key != null && obj instanceof Map map) { return map.get(key); } @@ -93,8 +92,7 @@ public class Format implements Convert.Support { return false; if (obj instanceof Style) return false; - if (obj instanceof Format) { - Format format = (Format)obj; + if (obj instanceof Format format) { return format.hasValue(); } return true; @@ -112,8 +110,7 @@ public class Format implements Convert.Support { return null; if (obj instanceof Style) return null; - if (obj instanceof Format) { - Format format = (Format)obj; + if (obj instanceof Format format) { if (format.key != null) return format.key; return null; @@ -133,10 +130,10 @@ public class Format implements Convert.Support { * @return 현재 Format */ public Format style(Object obj) { - if (obj instanceof Style) { - cellStyle = cellStyle((Style)obj); - } else if (obj instanceof CellStyle) { - cellStyle = (CellStyle)obj; + if (obj instanceof Style style) { + cellStyle = cellStyle(style); + } else if (obj instanceof CellStyle style) { + cellStyle = style; } else throw new IllegalArgumentException("Unable to get a CellStyle from " + obj); diff --git a/src/main/java/cokr/xit/base/docs/xls/XLSWriter.java b/src/main/java/cokr/xit/base/docs/xls/XLSWriter.java index c3aa71c..b4f5016 100644 --- a/src/main/java/cokr/xit/base/docs/xls/XLSWriter.java +++ b/src/main/java/cokr/xit/base/docs/xls/XLSWriter.java @@ -86,8 +86,7 @@ public class XLSWriter extends XLS { if (!isEmpty(t)) { int c = cell.getColumnIndex(); if (isEmpty(objs)) { - if (t instanceof Map) { - Map map = (Map)t; + if (t instanceof Map map) { objs = map.keySet().stream().map(v -> (Object)v).toList(); } else if (t instanceof Iterable) { objs = (Iterable)t; @@ -103,15 +102,15 @@ public class XLSWriter extends XLS { Object val = null; Format format = null; - if (obj instanceof Format) - format = (Format)obj; + if (obj instanceof Format fmt) + format = fmt; if (format != null) val = format.value(t); else { Object key = Format.getKey(obj); - if (key != null && t instanceof Map) - val = ((Map)t).get(key); + if (key != null && t instanceof Map map) + val = map.get(key); else val = obj; } @@ -253,18 +252,16 @@ public class XLSWriter extends XLS { } boolean setCellValue(Object val) { - if (val instanceof String) { - cell.setCellValue((String)val); + if (val instanceof String str) { + cell.setCellValue(str); return true; - } else if (val instanceof Number) { - Number number = (Number)val; + } else if (val instanceof Number number) { cell.setCellValue(number.doubleValue()); return true; - } else if (val instanceof Date) { - cell.setCellValue((Date)val); + } else if (val instanceof Date date) { + cell.setCellValue(date); return true; - } else if (val instanceof Boolean) { - Boolean b = (Boolean)val; + } else if (val instanceof Boolean b) { cell.setCellValue(b.booleanValue()); return true; } @@ -284,12 +281,12 @@ public class XLSWriter extends XLS { void setCellStyle(Object obj) { CellStyle cellStyle = null; - if (obj instanceof Format) - cellStyle = ((Format)obj).style(); - else if (obj instanceof Style) - cellStyle = cellStyle((Style)obj); - else if (obj instanceof CellStyle) - cellStyle = (CellStyle)obj; + if (obj instanceof Format format) + cellStyle = format.style(); + else if (obj instanceof Style style) + cellStyle = cellStyle(style); + else if (obj instanceof CellStyle style) + cellStyle = style; if (cellStyle != null) cell.setCellStyle(cellStyle);