feat: Add Lombok @Getter and @Setter annotations to reduce boilerplate code in multiple classes (#4321)

# Description of Changes

Update classes across the codebase to use Lombok's `@Getter` and
`@Setter` annotations, replacing manually written getter and setter
methods. This change streamlines the code, reduces boilerplate, and
improves maintainability.

<!--
Please provide a summary of the changes, including:

- What was changed
- Why the change was made
- Any challenges encountered

Closes #(issue_number)
-->

---

## Checklist

### General

- [x] I have read the [Contribution
Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md)
- [x] I have read the [Stirling-PDF Developer
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md)
(if applicable)
- [ ] I have read the [How to add new languages to
Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md)
(if applicable)
- [x] I have performed a self-review of my own code
- [x] My changes generate no new warnings

### Documentation

- [ ] I have updated relevant docs on [Stirling-PDF's doc
repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/)
(if functionality has heavily changed)
- [ ] I have read the section [Add New Translation
Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags)
(for new translation tags only)

### UI Changes (if applicable)

- [ ] Screenshots or videos demonstrating the UI changes are attached
(e.g., as comments or direct attachments in the PR)

### Testing (if applicable)

- [x] I have tested my changes locally. Refer to the [Testing
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing)
for more details.

---------

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Balázs Szücs 2025-09-04 15:29:55 +02:00 committed by GitHub
parent 9a213c4bf6
commit fe84b3ff15
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 63 additions and 153 deletions

View File

@ -15,6 +15,8 @@ import java.util.concurrent.TimeUnit;
import io.github.pixee.security.BoundedLineReader;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import stirling.software.common.model.ApplicationProperties;
@ -303,6 +305,8 @@ public class ProcessExecutor {
OCR_MY_PDF
}
@Setter
@Getter
public class ProcessExecutorResult {
int rc;
String messages;
@ -312,20 +316,5 @@ public class ProcessExecutor {
this.messages = messages;
}
public int getRc() {
return rc;
}
public void setRc(int rc) {
this.rc = rc;
}
public String getMessages() {
return messages;
}
public void setMessages(String messages) {
this.messages = messages;
}
}
}

View File

@ -4,6 +4,7 @@ import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
/**
@ -14,6 +15,7 @@ import lombok.extern.slf4j.Slf4j;
public class TempFile implements AutoCloseable {
private final TempFileManager manager;
@Getter
private final File file;
public TempFile(TempFileManager manager, String suffix) throws IOException {
@ -21,10 +23,6 @@ public class TempFile implements AutoCloseable {
this.file = manager.createTempFile(suffix);
}
public File getFile() {
return file;
}
public Path getPath() {
return file.toPath();
}

View File

@ -11,6 +11,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.stream.Collectors;
import lombok.Getter;
import org.springframework.stereotype.Component;
import lombok.extern.slf4j.Slf4j;
@ -24,8 +25,22 @@ import lombok.extern.slf4j.Slf4j;
public class TempFileRegistry {
private final ConcurrentMap<Path, Instant> registeredFiles = new ConcurrentHashMap<>();
/**
* -- GETTER --
* Get all registered third-party temporary files.
*
* @return Set of third-party file paths
*/
@Getter
private final Set<Path> thirdPartyTempFiles =
Collections.newSetFromMap(new ConcurrentHashMap<>());
/**
* -- GETTER --
* Get all registered temporary directories.
*
* @return Set of temporary directory paths
*/
@Getter
private final Set<Path> tempDirectories = Collections.newSetFromMap(new ConcurrentHashMap<>());
/**
@ -133,24 +148,6 @@ public class TempFileRegistry {
.collect(Collectors.toSet());
}
/**
* Get all registered third-party temporary files.
*
* @return Set of third-party file paths
*/
public Set<Path> getThirdPartyTempFiles() {
return thirdPartyTempFiles;
}
/**
* Get all registered temporary directories.
*
* @return Set of temporary directory paths
*/
public Set<Path> getTempDirectories() {
return tempDirectories;
}
/**
* Check if a file is registered in the registry.
*

View File

@ -31,6 +31,8 @@ import java.security.cert.X509Certificate;
import java.util.Arrays;
import java.util.Enumeration;
import lombok.Getter;
import lombok.Setter;
import org.apache.pdfbox.pdmodel.interactive.digitalsignature.SignatureInterface;
import org.bouncycastle.cert.jcajce.JcaCertStore;
import org.bouncycastle.cms.CMSException;
@ -44,8 +46,21 @@ import org.bouncycastle.operator.jcajce.JcaDigestCalculatorProviderBuilder;
public abstract class CreateSignatureBase implements SignatureInterface {
private PrivateKey privateKey;
@Getter
private Certificate[] certificateChain;
@Setter
private String tsaUrl;
/**
* Specifies whether the external signing scenario should be used.
* If set to {@code true}, external signing will be performed and
* {@link SignatureInterface} will be used for signing.
* If set to {@code false}, internal signing will be performed.
* <p>Default: {@code false}
*
* @param externalSigning {@code true} if external signing should be performed; {@code false} for internal signing
*/
@Setter
@Getter
private boolean externalSigning;
/**
@ -97,18 +112,10 @@ public abstract class CreateSignatureBase implements SignatureInterface {
this.privateKey = privateKey;
}
public Certificate[] getCertificateChain() {
return certificateChain;
}
public final void setCertificateChain(final Certificate[] certificateChain) {
this.certificateChain = certificateChain;
}
public void setTsaUrl(String tsaUrl) {
this.tsaUrl = tsaUrl;
}
/**
* SignatureInterface sample implementation.
*
@ -152,19 +159,4 @@ public abstract class CreateSignatureBase implements SignatureInterface {
}
}
public boolean isExternalSigning() {
return externalSigning;
}
/**
* Set if external signing scenario should be used. If {@code false}, SignatureInterface would
* be used for signing.
*
* <p>Default: {@code false}
*
* @param externalSigning {@code true} if external signing should be performed
*/
public void setExternalSigning(boolean externalSigning) {
this.externalSigning = externalSigning;
}
}

View File

@ -6,6 +6,7 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
@ -19,6 +20,7 @@ public class EndpointConfiguration {
private static final String REMOVE_BLANKS = "remove-blanks";
private final ApplicationProperties applicationProperties;
@Getter
private Map<String, Boolean> endpointStatuses = new ConcurrentHashMap<>();
private Map<String, Set<String>> endpointGroups = new ConcurrentHashMap<>();
private Set<String> disabledGroups = new HashSet<>();
@ -46,10 +48,6 @@ public class EndpointConfiguration {
endpointStatuses.put(endpoint, false);
}
public Map<String, Boolean> getEndpointStatuses() {
return endpointStatuses;
}
public boolean isEndpointEnabled(String endpoint) {
String original = endpoint;
if (endpoint.startsWith("/")) {

View File

@ -6,6 +6,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.Getter;
import lombok.Setter;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDDocumentOutline;
@ -234,33 +236,12 @@ public class EditTableOfContentsController {
}
// Inner class to represent bookmarks in JSON
@Setter
@Getter
public static class BookmarkItem {
private String title;
private int pageNumber;
private List<BookmarkItem> children = new ArrayList<>();
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public int getPageNumber() {
return pageNumber;
}
public void setPageNumber(int pageNumber) {
this.pageNumber = pageNumber;
}
public List<BookmarkItem> getChildren() {
return children;
}
public void setChildren(List<BookmarkItem> children) {
this.children = children;
}
}
}

View File

@ -9,6 +9,8 @@ import java.nio.file.Paths;
import java.util.*;
import java.util.stream.Stream;
import lombok.Getter;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
@ -317,6 +319,8 @@ public class GeneralWebController {
return "remove-image-pdf";
}
@Setter
@Getter
public class FontResource {
private String name;
@ -331,28 +335,5 @@ public class GeneralWebController {
this.type = getFormatFromExtension(extension);
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getExtension() {
return extension;
}
public void setExtension(String extension) {
this.extension = extension;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
}

View File

@ -4,6 +4,8 @@ import java.time.Duration;
import java.time.LocalDateTime;
import java.util.*;
import lombok.Getter;
import lombok.Setter;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
@ -362,6 +364,8 @@ public class MetricsController {
return String.format("%dd %dh %dm %ds", days, hours, minutes, seconds);
}
@Setter
@Getter
public static class EndpointCount {
private String endpoint;
@ -373,20 +377,5 @@ public class MetricsController {
this.count = count;
}
public String getEndpoint() {
return endpoint;
}
public void setEndpoint(String endpoint) {
this.endpoint = endpoint;
}
public double getCount() {
return count;
}
public void setCount(double count) {
this.count = count;
}
}
}

View File

@ -4,10 +4,12 @@ import java.util.HashMap;
import java.util.Map;
import com.fasterxml.jackson.databind.JsonNode;
import lombok.Getter;
public class ApiEndpoint {
private final String name;
private Map<String, JsonNode> parameters;
@Getter
private final String description;
public ApiEndpoint(String name, JsonNode postNode) {
@ -31,10 +33,6 @@ public class ApiEndpoint {
return true;
}
public String getDescription() {
return description;
}
@Override
public String toString() {
return "ApiEndpoint [name=" + name + ", parameters=" + parameters + "]";

View File

@ -79,10 +79,6 @@ public class ScannerEffectRequest {
@Schema(description = "Whether advanced settings are enabled", example = "false")
private boolean advancedEnabled = false;
public boolean isAdvancedEnabled() {
return advancedEnabled;
}
public int getQualityValue() {
return switch (quality) {
case low -> 30;

View File

@ -6,6 +6,7 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import lombok.Getter;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.text.PDFTextStripper;
import org.apache.pdfbox.text.TextPosition;
@ -20,6 +21,7 @@ public class TextFinder extends PDFTextStripper {
private final String searchTerm;
private final boolean useRegex;
private final boolean wholeWordSearch;
@Getter
private final List<PDFText> foundTexts = new ArrayList<>();
private final List<TextPosition> pageTextPositions = new ArrayList<>();
@ -187,10 +189,6 @@ public class TextFinder extends PDFTextStripper {
super.endPage(page);
}
public List<PDFText> getFoundTexts() {
return foundTexts;
}
public String getDebugInfo() {
StringBuilder debug = new StringBuilder();
debug.append("Extracted text length: ").append(pageTextBuilder.length()).append("\n");

View File

@ -1,6 +1,9 @@
package stirling.software.proprietary.audit;
import lombok.Getter;
/** Standardized audit event types for the application. */
@Getter
public enum AuditEventType {
// Authentication events - BASIC level
USER_LOGIN("User login"),
@ -28,10 +31,6 @@ public enum AuditEventType {
this.description = description;
}
public String getDescription() {
return description;
}
/**
* Get the enum value from a string representation. Useful for backward compatibility with
* string-based event types.

View File

@ -1,6 +1,9 @@
package stirling.software.proprietary.audit;
import lombok.Getter;
/** Defines the different levels of audit logging available in the application. */
@Getter
public enum AuditLevel {
/**
* OFF - No audit logging (level 0) Disables all audit logging except for critical security
@ -33,10 +36,6 @@ public enum AuditLevel {
this.level = level;
}
public int getLevel() {
return level;
}
/**
* Checks if this audit level includes the specified level
*

View File

@ -1,5 +1,8 @@
package stirling.software.proprietary.security.model;
import lombok.Getter;
@Getter
public class AttemptCounter {
private int attemptCount;
private long lastAttemptTime;
@ -14,14 +17,6 @@ public class AttemptCounter {
this.lastAttemptTime = System.currentTimeMillis();
}
public int getAttemptCount() {
return attemptCount;
}
public long getLastAttemptTime() {
return lastAttemptTime;
}
public boolean shouldReset(long attemptIncrementTime) {
return System.currentTimeMillis() - lastAttemptTime > attemptIncrementTime;
}