core = pkg.getRelationshipsByType(CORE_DOCUMENT_REL);
// If nothing was found, try some of the other OOXML-based core types
- if (core.size() == 0) {
+ if (core.isEmpty()) {
// Could it be an OOXML-Strict one?
core = pkg.getRelationshipsByType(STRICT_DOCUMENT_REL);
}
- if (core.size() == 0) {
+ if (core.isEmpty()) {
// Could it be a visio one?
core = pkg.getRelationshipsByType(VISIO_DOCUMENT_REL);
if (core.size() == 1) {
@Override
public boolean hasRelationships() {
- return (relationships.size() > 0);
+ return !relationships.isEmpty();
}
@Override
public boolean isStrictOoxmlFormat() {
PackageRelationshipCollection coreDocRelationships = getRelationshipsByType(
PackageRelationshipTypes.STRICT_CORE_DOCUMENT);
- return coreDocRelationships.size() > 0;
+ return !coreDocRelationships.isEmpty();
}
/**
*/
@Override
public boolean hasRelationships() {
- return (!this._isRelationshipPart && (_relationships != null && _relationships
- .size() > 0));
+ return (!this._isRelationshipPart && (_relationships != null && !_relationships.isEmpty()));
}
/**
throw new IllegalStateException(e);
}
- if(notes.size() == 0) {
+ if(notes.isEmpty()) {
// No notes for this slide
return null;
}
throw new IllegalStateException(e);
}
- if(commentRels.size() == 0) {
+ if(commentRels.isEmpty()) {
// No comments for this slide
return null;
}
try {
PackageRelationshipCollection commentsList =
sheetPkg.getRelationshipsByType(XSSFRelation.SHEET_COMMENTS.getRelation());
- if (commentsList.size() > 0) {
+ if (!commentsList.isEmpty()) {
PackageRelationship comments = commentsList.getRelationship(0);
if (comments == null || comments.getTargetURI() == null) {
return null;
try {
PackageRelationshipCollection commentsList =
sheetPkg.getRelationshipsByType(XSSFRelation.SHEET_COMMENTS.getRelation());
- if (commentsList.size() > 0) {
+ if (!commentsList.isEmpty()) {
PackageRelationship comments = commentsList.getRelationship(0);
PackagePartName commentsName = PackagingURIHelper.createPartName(comments.getTargetURI());
PackagePart commentsPart = sheetPkg.getPackage().getPart(commentsName);
// Do we have a shapes relationship? (Only ever one if so)
try {
PackageRelationshipCollection drawingsList = sheetPkg.getRelationshipsByType(XSSFRelation.DRAWINGS.getRelation());
- for (int i = 0; i < drawingsList.size(); i++) {
+ int drawingsSize = drawingsList.size();
+ for (int i = 0; i < drawingsSize; i++) {
PackageRelationship drawings = drawingsList.getRelationship(i);
PackagePartName drawingsName = PackagingURIHelper.createPartName(drawings.getTargetURI());
PackagePart drawingsPart = sheetPkg.getPackage().getPart(drawingsName);
package org.apache.poi.openxml4j.opc;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
// Open the newly created file to check core properties saved values.
try (OPCPackage p2 = OPCPackage.open(outputFile.getAbsolutePath(), PackageAccess.READ)) {
- assertNotEquals(0, p2.getRelationshipsByType(PackageRelationshipTypes.THUMBNAIL).size(),
+ assertFalse(p2.getRelationshipsByType(PackageRelationshipTypes.THUMBNAIL).isEmpty(),
"Thumbnail not added to the package !");
p2.revert();
}