diff options
author | PJ Fanning <fanningpj@apache.org> | 2021-12-30 20:34:10 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2021-12-30 20:34:10 +0000 |
commit | 9de29ea3fcc63dc434d3337e56fb504e71262fb5 (patch) | |
tree | 3a218cb5c23df283c566362ac6c194cd8c06fcb1 /poi-ooxml | |
parent | 15b1c51f3397950fb35a4419924c71cedee6c068 (diff) | |
download | poi-9de29ea3fcc63dc434d3337e56fb504e71262fb5.tar.gz poi-9de29ea3fcc63dc434d3337e56fb504e71262fb5.zip |
use isEmpty()
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1896541 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-ooxml')
13 files changed, 19 insertions, 19 deletions
diff --git a/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/ZipPackage.java b/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/ZipPackage.java index af1a4c07b1..bf91ad17b0 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/ZipPackage.java +++ b/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/ZipPackage.java @@ -537,8 +537,8 @@ public final class ZipPackage extends OPCPackage { try { // If the core properties part does not exist in the part list, // we save it as well - if (this.getPartsByRelationshipType(PackageRelationshipTypes.CORE_PROPERTIES).size() == 0 && - this.getPartsByRelationshipType(PackageRelationshipTypes.CORE_PROPERTIES_ECMA376).size() == 0 ) { + if (this.getPartsByRelationshipType(PackageRelationshipTypes.CORE_PROPERTIES).isEmpty() && + this.getPartsByRelationshipType(PackageRelationshipTypes.CORE_PROPERTIES_ECMA376).isEmpty()) { LOG.atDebug().log("Save core properties part"); // Ensure that core properties are added if missing diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/eventusermodel/XSSFBReader.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/eventusermodel/XSSFBReader.java index d9a24bb855..9a02bcb4a0 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/eventusermodel/XSSFBReader.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/eventusermodel/XSSFBReader.java @@ -108,7 +108,7 @@ public class XSSFBReader extends XSSFReader { public XSSFBStylesTable getXSSFBStylesTable() throws IOException { ArrayList<PackagePart> parts = pkg.getPartsByContentType(XSSFBRelation.STYLES_BINARY.getContentType()); - if(parts.size() == 0) return null; + if(parts.isEmpty()) return null; // Create the Styles Table, and associate the Themes if present try (InputStream stream = parts.get(0).getInputStream()) { diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/eventusermodel/XSSFReader.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/eventusermodel/XSSFReader.java index 220f5b89c4..64ed7297ee 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/eventusermodel/XSSFReader.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/eventusermodel/XSSFReader.java @@ -144,7 +144,7 @@ public class XSSFReader { public SharedStrings getSharedStringsTable() throws IOException, InvalidFormatException { ArrayList<PackagePart> parts = pkg.getPartsByContentType(XSSFRelation.SHARED_STRINGS.getContentType()); try { - return parts.size() == 0 ? null : + return parts.isEmpty() ? null : useReadOnlySharedStringsTable ? new ReadOnlySharedStringsTable(parts.get(0)) : new SharedStringsTable(parts.get(0)); } catch (SAXException se) { @@ -158,7 +158,7 @@ public class XSSFReader { */ public StylesTable getStylesTable() throws IOException, InvalidFormatException { ArrayList<PackagePart> parts = pkg.getPartsByContentType(XSSFRelation.STYLES.getContentType()); - if (parts.size() == 0) return null; + if (parts.isEmpty()) return null; // Create the Styles Table, and associate the Themes if present StylesTable styles = new StylesTable(parts.get(0)); diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFSheet.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFSheet.java index d4e22810b2..38ff3d3e09 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFSheet.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFSheet.java @@ -198,7 +198,7 @@ public class SXSSFSheet implements Sheet, OoxmlSheetExtensions { if(_writer.getNumberOfFlushedRows() > 0) { return _writer.getLowestIndexOfFlushedRows(); } - return _rows.size() == 0 ? -1 : _rows.firstKey(); + return _rows.isEmpty() ? -1 : _rows.firstKey(); } /** @@ -208,7 +208,7 @@ public class SXSSFSheet implements Sheet, OoxmlSheetExtensions { */ @Override public int getLastRowNum() { - return _rows.size() == 0 ? -1 : _rows.lastKey(); + return _rows.isEmpty() ? -1 : _rows.lastKey(); } /** diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFRow.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFRow.java index 85543d5ff0..15859f4fdb 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFRow.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFRow.java @@ -304,7 +304,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> { */ @Override public short getFirstCellNum() { - return (short)(_cells.size() == 0 ? -1 : _cells.firstKey()); + return (short)(_cells.isEmpty() ? -1 : _cells.firstKey()); } /** @@ -328,7 +328,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> { */ @Override public short getLastCellNum() { - return (short)(_cells.size() == 0 ? -1 : (_cells.lastKey() + 1)); + return (short)(_cells.isEmpty() ? -1 : (_cells.lastKey() + 1)); } /** diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java index 9f69900ec8..50ab442b15 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java @@ -2835,7 +2835,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet, OoxmlSheetEx */ @Beta public void copyRows(List<? extends Row> srcRows, int destStartRow, CellCopyPolicy policy) { - if (srcRows == null || srcRows.size() == 0) { + if (srcRows == null || srcRows.isEmpty()) { throw new IllegalArgumentException("No rows to copy"); } final Row srcStartRow = srcRows.get(0); diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java index ec17fa8809..0552d8182f 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java @@ -1383,7 +1383,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Date1904Su sheets.remove(index); // only set new sheet if there are still some left - if(sheets.size() == 0) { + if(sheets.isEmpty()) { return; } diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFAbstractFootnoteEndnote.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFAbstractFootnoteEndnote.java index 7c97b908cd..0be1a2f74b 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFAbstractFootnoteEndnote.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFAbstractFootnoteEndnote.java @@ -503,7 +503,7 @@ public abstract class XWPFAbstractFootnoteEndnote implements Iterable<XWPFParag */ public XWPFTable createTable() { XWPFTable table = new XWPFTable(ctFtnEdn.addNewTbl(), this); - if (bodyElements.size() == 0) { + if (bodyElements.isEmpty()) { XWPFParagraph p = createParagraph(); ensureFootnoteRef(p); } diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java index f65667c55d..7274f9bbe7 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java @@ -618,7 +618,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody { */ private int getBodyElementSpecificPos(int pos, List<? extends IBodyElement> list) { // If there's nothing to find, skip it - if (list.size() == 0) { + if (list.isEmpty()) { return -1; } diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java index fea3e33b48..a839c587cf 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java @@ -603,7 +603,7 @@ public abstract class XWPFHeaderFooter extends POIXMLDocumentPart implements IBo @Override protected void prepareForCommit() { // must contain at least an empty paragraph - if (bodyElements.size() == 0) { + if (bodyElements.isEmpty()) { createParagraph(); } @@ -611,7 +611,7 @@ public abstract class XWPFHeaderFooter extends POIXMLDocumentPart implements IBo for (XWPFTable tbl : tables) { for (XWPFTableRow row : tbl.tableRows) { for (XWPFTableCell cell : row.getTableCells()) { - if (cell.getBodyElements().size() == 0) { + if (cell.getBodyElements().isEmpty()) { cell.addParagraph(); } } diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTable.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTable.java index 971ea0ffd5..00247afc92 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTable.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTable.java @@ -237,10 +237,10 @@ public class XWPFTable implements IBodyElement, ISDTContents { /** * Add a new cell at the end of each row in this table, creating a new column. * If rows have different numbers of columns, will still append a cell to each row. - * Currently does not match the width of existing columns. + * Currently, does not match the width of existing columns. */ public void addNewCol() { - if (tableRows.size() == 0) { + if (tableRows.isEmpty()) { createRow(); } for (XWPFTableRow tableRow : tableRows) { diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java index b81cde1eee..fe3140613a 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java @@ -441,7 +441,7 @@ public class XWPFTableCell implements IBody, ICell { } public void setText(String text) { - XWPFParagraph par = (paragraphs.size() == 0) ? addParagraph() : paragraphs.get(0); + XWPFParagraph par = paragraphs.isEmpty() ? addParagraph() : paragraphs.get(0); par.createRun().setText(text); } diff --git a/poi-ooxml/src/test/java/org/apache/poi/xssf/TestXSSFXLookupFunction.java b/poi-ooxml/src/test/java/org/apache/poi/xssf/TestXSSFXLookupFunction.java index dbe7c956fc..81fe37b623 100644 --- a/poi-ooxml/src/test/java/org/apache/poi/xssf/TestXSSFXLookupFunction.java +++ b/poi-ooxml/src/test/java/org/apache/poi/xssf/TestXSSFXLookupFunction.java @@ -31,7 +31,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; /** * Testcase for function XLOOKUP() */ -public class TestXSSFXLookupFunction { +class TestXSSFXLookupFunction { //https://support.microsoft.com/en-us/office/xlookup-function-b7fd680e-6d10-43e6-84f9-88eae8bf5929 |