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();
pdfDocument.close();
switch (comparator.toLowerCase()) {
case "greater":
return actualPageCount > pageCount;
case "equal":
return actualPageCount == pageCount;
case "less":
return actualPageCount < pageCount;
default:
return switch (comparator.toLowerCase()) {
case "greater" -> actualPageCount > pageCount;
case "equal" -> actualPageCount == pageCount;
case "less" -> actualPageCount < pageCount;
default ->
throw ExceptionUtils.createInvalidArgumentException("comparator", comparator);
}
};
}
public boolean pageSize(PDDocument pdfDocument, String expectedPageSize) throws IOException {
@ -602,9 +599,15 @@ public class PdfUtils {
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) {
}
}