mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-09-12 17:52:13 +02:00
#length() -> #isEmtpty()
This commit is contained in:
parent
b26ecbc3b7
commit
3973adbae9
@ -51,7 +51,7 @@ public class CleanUrlInterceptor implements HandlerInterceptor {
|
||||
// Construct new query string
|
||||
StringBuilder newQueryString = new StringBuilder();
|
||||
for (Map.Entry<String, String> entry : allowedParameters.entrySet()) {
|
||||
if (newQueryString.length() > 0) {
|
||||
if (!newQueryString.isEmpty()) {
|
||||
newQueryString.append("&");
|
||||
}
|
||||
newQueryString.append(entry.getKey()).append("=").append(entry.getValue());
|
||||
|
@ -124,7 +124,7 @@ public class UserService implements UserServiceInterface {
|
||||
User user =
|
||||
findByUsernameIgnoreCase(username)
|
||||
.orElseThrow(() -> new UsernameNotFoundException("User not found"));
|
||||
if (user.getApiKey() == null || user.getApiKey().length() == 0) {
|
||||
if (user.getApiKey() == null || user.getApiKey().isEmpty()) {
|
||||
user = addApiKeyToUser(username);
|
||||
}
|
||||
return user.getApiKey();
|
||||
|
@ -258,7 +258,7 @@ public class RearrangePagesPDFController {
|
||||
int totalPages = document.getNumberOfPages();
|
||||
List<Integer> newPageOrder;
|
||||
if (sortType != null
|
||||
&& sortType.length() > 0
|
||||
&& !sortType.isEmpty()
|
||||
&& !"custom".equals(sortType.toLowerCase())) {
|
||||
newPageOrder = processSortTypes(sortType, totalPages, pageOrder);
|
||||
} else {
|
||||
|
@ -75,7 +75,7 @@ public class AutoRenameController {
|
||||
}
|
||||
|
||||
private void processLine() {
|
||||
if (lineBuilder.length() > 0 && lineCount < LINE_LIMIT) {
|
||||
if (!lineBuilder.isEmpty() && lineCount < LINE_LIMIT) {
|
||||
lineInfos.add(new LineInfo(lineBuilder.toString(), maxFontSizeInLine));
|
||||
}
|
||||
}
|
||||
|
@ -331,9 +331,8 @@ public class CompressController {
|
||||
|
||||
// Get original image from a reference
|
||||
private PDImageXObject getOriginalImage(PDDocument doc, ImageReference ref) throws IOException {
|
||||
if (ref instanceof NestedImageReference) {
|
||||
if (ref instanceof NestedImageReference nestedRef) {
|
||||
// Get the nested image from within a form XObject
|
||||
NestedImageReference nestedRef = (NestedImageReference) ref;
|
||||
PDPage page = doc.getPage(nestedRef.pageNum);
|
||||
PDResources pageResources = page.getResources();
|
||||
|
||||
@ -409,9 +408,8 @@ public class CompressController {
|
||||
// Replace a specific image reference with a compressed version
|
||||
private void replaceImageReference(
|
||||
PDDocument doc, ImageReference ref, PDImageXObject compressedImage) throws IOException {
|
||||
if (ref instanceof NestedImageReference) {
|
||||
if (ref instanceof NestedImageReference nestedRef) {
|
||||
// Replace nested image within form XObject
|
||||
NestedImageReference nestedRef = (NestedImageReference) ref;
|
||||
PDPage page = doc.getPage(nestedRef.pageNum);
|
||||
PDResources pageResources = page.getResources();
|
||||
|
||||
@ -626,32 +624,32 @@ public class CompressController {
|
||||
|
||||
// Scale factors for different optimization levels
|
||||
private double getScaleFactorForLevel(int optimizeLevel) {
|
||||
return switch (optimizeLevel) {
|
||||
case 3 -> 0.85;
|
||||
case 4 -> 0.75;
|
||||
case 5 -> 0.65;
|
||||
case 6 -> 0.55;
|
||||
case 7 -> 0.45;
|
||||
case 8 -> 0.35;
|
||||
case 9 -> 0.25;
|
||||
case 10 -> 0.15;
|
||||
default -> 1.0;
|
||||
};
|
||||
return switch (optimizeLevel) {
|
||||
case 3 -> 0.85;
|
||||
case 4 -> 0.75;
|
||||
case 5 -> 0.65;
|
||||
case 6 -> 0.55;
|
||||
case 7 -> 0.45;
|
||||
case 8 -> 0.35;
|
||||
case 9 -> 0.25;
|
||||
case 10 -> 0.15;
|
||||
default -> 1.0;
|
||||
};
|
||||
}
|
||||
|
||||
// JPEG quality for different optimization levels
|
||||
private float getJpegQualityForLevel(int optimizeLevel) {
|
||||
return switch (optimizeLevel) {
|
||||
case 3 -> 0.85f;
|
||||
case 4 -> 0.80f;
|
||||
case 5 -> 0.75f;
|
||||
case 6 -> 0.70f;
|
||||
case 7 -> 0.60f;
|
||||
case 8 -> 0.50f;
|
||||
case 9 -> 0.35f;
|
||||
case 10 -> 0.2f;
|
||||
default -> 0.7f;
|
||||
};
|
||||
return switch (optimizeLevel) {
|
||||
case 3 -> 0.85f;
|
||||
case 4 -> 0.80f;
|
||||
case 5 -> 0.75f;
|
||||
case 6 -> 0.70f;
|
||||
case 7 -> 0.60f;
|
||||
case 8 -> 0.50f;
|
||||
case 9 -> 0.35f;
|
||||
case 10 -> 0.2f;
|
||||
default -> 0.7f;
|
||||
};
|
||||
}
|
||||
|
||||
@PostMapping(consumes = "multipart/form-data", value = "/compress-pdf")
|
||||
@ -672,7 +670,7 @@ public class CompressController {
|
||||
|
||||
Long expectedOutputSize = 0L;
|
||||
boolean autoMode = false;
|
||||
if (expectedOutputSizeString != null && expectedOutputSizeString.length() > 1) {
|
||||
if (expectedOutputSizeString != null && !expectedOutputSizeString.isEmpty()) {
|
||||
expectedOutputSize = GeneralUtils.convertSizeToBytes(expectedOutputSizeString);
|
||||
autoMode = true;
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ public class MetadataController {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (creationDate != null && creationDate.length() > 0) {
|
||||
if (creationDate != null && !creationDate.isEmpty()) {
|
||||
Calendar creationDateCal = Calendar.getInstance();
|
||||
try {
|
||||
creationDateCal.setTime(
|
||||
@ -155,7 +155,7 @@ public class MetadataController {
|
||||
} else {
|
||||
info.setCreationDate(null);
|
||||
}
|
||||
if (modificationDate != null && modificationDate.length() > 0) {
|
||||
if (modificationDate != null && !modificationDate.isEmpty()) {
|
||||
Calendar modificationDateCal = Calendar.getInstance();
|
||||
try {
|
||||
modificationDateCal.setTime(
|
||||
|
@ -74,7 +74,7 @@ public class GeneralWebController {
|
||||
new ObjectMapper()
|
||||
.readValue(config, new TypeReference<Map<String, Object>>() {});
|
||||
String name = (String) jsonContent.get("name");
|
||||
if (name == null || name.length() < 1) {
|
||||
if (name == null || name.isEmpty()) {
|
||||
String filename =
|
||||
jsonFiles
|
||||
.get(pipelineConfigs.indexOf(config))
|
||||
|
@ -361,19 +361,17 @@ public class ApplicationProperties {
|
||||
private List<String> languages;
|
||||
|
||||
public String getAppName() {
|
||||
return appName != null && appName.trim().length() > 0 ? appName : null;
|
||||
return appName != null && !appName.trim().isEmpty() ? appName : null;
|
||||
}
|
||||
|
||||
public String getHomeDescription() {
|
||||
return homeDescription != null && homeDescription.trim().length() > 0
|
||||
return homeDescription != null && !homeDescription.trim().isEmpty()
|
||||
? homeDescription
|
||||
: null;
|
||||
}
|
||||
|
||||
public String getAppNameNavbar() {
|
||||
return appNameNavbar != null && appNameNavbar.trim().length() > 0
|
||||
? appNameNavbar
|
||||
: null;
|
||||
return appNameNavbar != null && !appNameNavbar.trim().isEmpty() ? appNameNavbar : null;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user