refactor: replace traditional switch statement with modern switch expression

This commit is contained in:
Balázs Szücs 2025-08-02 11:27:49 +02:00
parent 187f93c949
commit d526b94f44

View File

@ -571,16 +571,13 @@ public class PdfUtils {
int actualPageCount = pdfDocument.getNumberOfPages(); int actualPageCount = pdfDocument.getNumberOfPages();
pdfDocument.close(); pdfDocument.close();
switch (comparator.toLowerCase()) { return switch (comparator.toLowerCase()) {
case "greater": case "greater" -> actualPageCount > pageCount;
return actualPageCount > pageCount; case "equal" -> actualPageCount == pageCount;
case "equal": case "less" -> actualPageCount < pageCount;
return actualPageCount == pageCount; default ->
case "less":
return actualPageCount < pageCount;
default:
throw ExceptionUtils.createInvalidArgumentException("comparator", comparator); throw ExceptionUtils.createInvalidArgumentException("comparator", comparator);
} };
} }
public boolean pageSize(PDDocument pdfDocument, String expectedPageSize) throws IOException { public boolean pageSize(PDDocument pdfDocument, String expectedPageSize) throws IOException {
@ -602,9 +599,15 @@ public class PdfUtils {
return actualPageWidth == expectedPageWidth && actualPageHeight == expectedPageHeight; return actualPageWidth == expectedPageWidth && actualPageHeight == expectedPageHeight;
} }
/** Key for storing the dimensions of a rendered image in a map. */ /**
private record PdfRenderSettingsKey(float mediaBoxWidth, float mediaBoxHeight, int rotation) {} * Key for storing the dimensions of a rendered image in a map.
*/
private record PdfRenderSettingsKey(float mediaBoxWidth, float mediaBoxHeight, int rotation) {
}
/** Value for storing the dimensions of a rendered image in a map. */ /**
private record PdfImageDimensionValue(int width, int height) {} * Value for storing the dimensions of a rendered image in a map.
*/
private record PdfImageDimensionValue(int width, int height) {
}
} }