diff --git a/README.md b/README.md
index bcfe915..92a98dd 100644
--- a/README.md
+++ b/README.md
@@ -261,12 +261,12 @@ public class SpringQueryFilter implements ISpringQueryFilter {
private String sort;
@Override
- public int getPage() {
+ public int getComputedPage() {
return Math.max(Optional.ofNullable(page).orElse(0), 0);
}
@Override
- public int getPageSize() {
+ public int getComputedSize() {
return Math.clamp(Optional.ofNullable(pageSize).orElse(DEFAULT_PAGE_SIZE), MIN_PAGE_SIZE, MAX_PAGE_SIZE);
}
diff --git a/changelog.md b/changelog.md
index 0f5778f..f01f926 100644
--- a/changelog.md
+++ b/changelog.md
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
+## [Unreleased]
+
+### Fixed
+
+- Add missing module-info.java.
+
+### Removed
+
+- Lombok dependency.
+
## [1.1.1] 2024/11/18
### Fixed
diff --git a/pom.xml b/pom.xml
index c927d69..4303cbf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
@@ -79,9 +77,17 @@ public enum PredicateOperator {
/**
* Operator value.
*/
- @Getter
private final String value;
+ /**
+ * Gets the operator value.
+ *
+ * @return the operator value.
+ */
+ public String getValue() {
+ return value;
+ }
+
/**
* Constructor to assign the string value to each operator.
*
diff --git a/src/main/java/io/github/zorin95670/query/ISpringQueryFilter.java b/src/main/java/io/github/zorin95670/query/ISpringQueryFilter.java
index b2156b0..f7fdf99 100644
--- a/src/main/java/io/github/zorin95670/query/ISpringQueryFilter.java
+++ b/src/main/java/io/github/zorin95670/query/ISpringQueryFilter.java
@@ -19,14 +19,14 @@ public interface ISpringQueryFilter {
*
* @return the page number (0-based index).
*/
- int getPage();
+ int getComputedPage();
/**
* Retrieves the page size for pagination.
*
* @return the number of records per page.
*/
- int getPageSize();
+ int getComputedPageSize();
/**
* Retrieves the field by which results should be ordered.
@@ -81,9 +81,9 @@ default Pageable getPageable(String defaultOrder) {
Sort sort = this.getOrderBy(defaultOrder);
if (sort != null) {
- return PageRequest.of(this.getPage(), this.getPageSize(), sort);
+ return PageRequest.of(this.getComputedPage(), this.getComputedPageSize(), sort);
}
- return PageRequest.of(this.getPage(), this.getPageSize());
+ return PageRequest.of(this.getComputedPage(), this.getComputedPageSize());
}
}
diff --git a/src/main/java/io/github/zorin95670/query/SpringQueryFilter.java b/src/main/java/io/github/zorin95670/query/SpringQueryFilter.java
index 96d0134..303e212 100644
--- a/src/main/java/io/github/zorin95670/query/SpringQueryFilter.java
+++ b/src/main/java/io/github/zorin95670/query/SpringQueryFilter.java
@@ -1,16 +1,11 @@
package io.github.zorin95670.query;
-import lombok.AllArgsConstructor;
-import lombok.NoArgsConstructor;
-
import java.util.Optional;
/**
* Class implementing {@link ISpringQueryFilter} for managing pagination and sorting parameters in a Spring application.
* This class provides default values for pagination and handles sorting direction based on the `sort` field.
*/
-@NoArgsConstructor
-@AllArgsConstructor
public class SpringQueryFilter implements ISpringQueryFilter {
/**
@@ -41,42 +36,93 @@ public class SpringQueryFilter implements ISpringQueryFilter {
/**
* Field name by which results should be ordered. Can be set to null.
*/
- private String order;
+ private String order = null;
/**
* Sorting direction. Should be "asc" for ascending order; any other value is treated as descending.
*/
- private String sort;
+ private String sort = null;
/**
- * Retrieves the page number for pagination, defaulting to 0 if the page is null or less than 0.
+ * Default no-argument constructor.
+ */
+ public SpringQueryFilter() {
+ }
+
+ /**
+ * Constructor to initialize all properties.
*
- * @return the page number, constrained to be non-negative.
+ * @param page the page number (0-based index).
+ * @param pageSize the number of records per page.
+ * @param order the field name by which results should be ordered.
+ * @param sort the sorting direction (ascending or descending).
*/
- @Override
- public int getPage() {
- return Math.max(Optional.ofNullable(page).orElse(0), 0);
+ public SpringQueryFilter(final Integer page, final Integer pageSize, final String order, final String sort) {
+ this.page = page;
+ this.pageSize = pageSize;
+ this.order = order;
+ this.sort = sort;
}
/**
- * Retrieves the page size for pagination, constrained between 1 and 10.
- * Defaults to 1 if page size is null or less than 1.
+ * Returns the page number for pagination (0-based index).
+ * Defaults to 0 if not specified.
*
- * @return the page size, bounded by a minimum of 1 and a maximum of 10.
+ * @return the page number (0-based index)
+ */
+ public Integer getPage() {
+ return page;
+ }
+
+ /**
+ * Returns the number of records per page.
+ * Defaults to 1 if not specified.
+ *
+ * @return the number of records per page
+ */
+ public Integer getPageSize() {
+ return pageSize;
+ }
+
+ /**
+ * Returns the field name by which results should be ordered.
+ * Can be set to null.
+ *
+ * @return the field name for ordering, or null if not specified
+ */
+ public String getOrder() {
+ return order;
+ }
+
+ /**
+ * Returns the sorting direction.
+ * Should be "asc" for ascending order; any other value is treated as descending.
+ *
+ * @return the sorting direction, either "asc" for ascending or any other value for descending
+ */
+ public String getSort() {
+ return sort;
+ }
+
+ /**
+ * Retrieves the page number for pagination, defaulting to 0 if the page is null or less than 0.
+ *
+ * @return the page number, constrained to be non-negative.
*/
@Override
- public int getPageSize() {
- return Math.clamp(Optional.ofNullable(pageSize).orElse(DEFAULT_PAGE_SIZE), MIN_PAGE_SIZE, MAX_PAGE_SIZE);
+ public int getComputedPage() {
+ return Math.max(Optional.ofNullable(getPage()).orElse(0), 0);
}
/**
- * Retrieves the field name by which results should be ordered.
+ * Retrieves the page size for pagination, constrained between 1 and 10.
+ * Defaults to 1 if page size is null or less than 1.
*
- * @return the order field, or null if not set.
+ * @return the page size, bounded by a minimum of 1 and a maximum of 10.
*/
@Override
- public String getOrder() {
- return this.order;
+ public int getComputedPageSize() {
+ return Math.clamp(Optional.ofNullable(getPageSize()).orElse(DEFAULT_PAGE_SIZE), MIN_PAGE_SIZE, MAX_PAGE_SIZE);
}
/**
@@ -86,6 +132,6 @@ public String getOrder() {
*/
@Override
public boolean isAscendantSort() {
- return "asc".equalsIgnoreCase(sort);
+ return "asc".equalsIgnoreCase(getSort());
}
}
diff --git a/src/main/java/io/github/zorin95670/specification/SpringQueryFilterSpecification.java b/src/main/java/io/github/zorin95670/specification/SpringQueryFilterSpecification.java
index 3ff9c39..fb9762b 100644
--- a/src/main/java/io/github/zorin95670/specification/SpringQueryFilterSpecification.java
+++ b/src/main/java/io/github/zorin95670/specification/SpringQueryFilterSpecification.java
@@ -15,8 +15,6 @@
import jakarta.persistence.criteria.CriteriaQuery;
import jakarta.persistence.criteria.Predicate;
import jakarta.persistence.criteria.Root;
-import lombok.Getter;
-import lombok.Setter;
import org.springframework.data.jpa.domain.Specification;
import java.lang.reflect.Field;
@@ -49,8 +47,7 @@ public class SpringQueryFilterSpecification