diff --git a/jpa/keyset-pagination/boot-data-window-pagination/lombok.config b/jpa/keyset-pagination/boot-data-window-pagination/lombok.config deleted file mode 100644 index 7a21e8804..000000000 --- a/jpa/keyset-pagination/boot-data-window-pagination/lombok.config +++ /dev/null @@ -1 +0,0 @@ -lombok.addLombokGeneratedAnnotation = true diff --git a/jpa/keyset-pagination/boot-data-window-pagination/pom.xml b/jpa/keyset-pagination/boot-data-window-pagination/pom.xml index cfd97c5b7..253d2ac10 100644 --- a/jpa/keyset-pagination/boot-data-window-pagination/pom.xml +++ b/jpa/keyset-pagination/boot-data-window-pagination/pom.xml @@ -63,11 +63,6 @@ spring-boot-configuration-processor true - - org.projectlombok - lombok - true - org.springframework.boot diff --git a/jpa/keyset-pagination/boot-data-window-pagination/src/main/java/com/example/keysetpagination/config/ApplicationProperties.java b/jpa/keyset-pagination/boot-data-window-pagination/src/main/java/com/example/keysetpagination/config/ApplicationProperties.java index f7862affd..7454825de 100644 --- a/jpa/keyset-pagination/boot-data-window-pagination/src/main/java/com/example/keysetpagination/config/ApplicationProperties.java +++ b/jpa/keyset-pagination/boot-data-window-pagination/src/main/java/com/example/keysetpagination/config/ApplicationProperties.java @@ -1,12 +1,10 @@ package com.example.keysetpagination.config; import jakarta.validation.Valid; -import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.NestedConfigurationProperty; import org.springframework.validation.annotation.Validated; -@Data @ConfigurationProperties("application") @Validated public class ApplicationProperties { @@ -15,12 +13,59 @@ public class ApplicationProperties { @Valid private Cors cors = new Cors(); - @Data + public Cors getCors() { + return cors; + } + + public void setCors(Cors cors) { + this.cors = cors; + } + public static class Cors { private String pathPattern = "/api/**"; private String allowedMethods = "*"; private String allowedHeaders = "*"; private String allowedOriginPatterns = "*"; private boolean allowCredentials = true; + + public boolean isAllowCredentials() { + return allowCredentials; + } + + public void setAllowCredentials(boolean allowCredentials) { + this.allowCredentials = allowCredentials; + } + + public String getAllowedHeaders() { + return allowedHeaders; + } + + public void setAllowedHeaders(String allowedHeaders) { + this.allowedHeaders = allowedHeaders; + } + + public String getAllowedMethods() { + return allowedMethods; + } + + public void setAllowedMethods(String allowedMethods) { + this.allowedMethods = allowedMethods; + } + + public String getAllowedOriginPatterns() { + return allowedOriginPatterns; + } + + public void setAllowedOriginPatterns(String allowedOriginPatterns) { + this.allowedOriginPatterns = allowedOriginPatterns; + } + + public String getPathPattern() { + return pathPattern; + } + + public void setPathPattern(String pathPattern) { + this.pathPattern = pathPattern; + } } } diff --git a/jpa/keyset-pagination/boot-data-window-pagination/src/main/java/com/example/keysetpagination/config/Initializer.java b/jpa/keyset-pagination/boot-data-window-pagination/src/main/java/com/example/keysetpagination/config/Initializer.java index 38fbb00a4..14c3ab2d7 100644 --- a/jpa/keyset-pagination/boot-data-window-pagination/src/main/java/com/example/keysetpagination/config/Initializer.java +++ b/jpa/keyset-pagination/boot-data-window-pagination/src/main/java/com/example/keysetpagination/config/Initializer.java @@ -1,17 +1,20 @@ package com.example.keysetpagination.config; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.boot.CommandLineRunner; import org.springframework.stereotype.Component; @Component -@RequiredArgsConstructor -@Slf4j class Initializer implements CommandLineRunner { + private static final Logger log = LoggerFactory.getLogger(Initializer.class); private final ApplicationProperties properties; + Initializer(ApplicationProperties properties) { + this.properties = properties; + } + @Override public void run(String... args) { log.info("Running Initializer....."); diff --git a/jpa/keyset-pagination/boot-data-window-pagination/src/main/java/com/example/keysetpagination/config/WebMvcConfig.java b/jpa/keyset-pagination/boot-data-window-pagination/src/main/java/com/example/keysetpagination/config/WebMvcConfig.java index f161bc105..74a03cea9 100644 --- a/jpa/keyset-pagination/boot-data-window-pagination/src/main/java/com/example/keysetpagination/config/WebMvcConfig.java +++ b/jpa/keyset-pagination/boot-data-window-pagination/src/main/java/com/example/keysetpagination/config/WebMvcConfig.java @@ -1,15 +1,17 @@ package com.example.keysetpagination.config; -import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @Configuration -@RequiredArgsConstructor class WebMvcConfig implements WebMvcConfigurer { private final ApplicationProperties properties; + WebMvcConfig(ApplicationProperties properties) { + this.properties = properties; + } + @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping(properties.getCors().getPathPattern()) diff --git a/jpa/keyset-pagination/boot-data-window-pagination/src/main/java/com/example/keysetpagination/entities/Animal.java b/jpa/keyset-pagination/boot-data-window-pagination/src/main/java/com/example/keysetpagination/entities/Animal.java index f1ac94a17..6791ee864 100644 --- a/jpa/keyset-pagination/boot-data-window-pagination/src/main/java/com/example/keysetpagination/entities/Animal.java +++ b/jpa/keyset-pagination/boot-data-window-pagination/src/main/java/com/example/keysetpagination/entities/Animal.java @@ -7,18 +7,11 @@ import jakarta.persistence.Id; import jakarta.persistence.Table; import jakarta.persistence.Version; -import java.time.LocalDateTime; import java.util.Objects; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; import org.hibernate.Hibernate; @Entity @Table(name = "animals", schema = "public") -@Getter -@NoArgsConstructor -@AllArgsConstructor public class Animal extends Auditable { @Id @@ -36,28 +29,54 @@ public class Animal extends Auditable { @Version private Short version; + public Animal() {} + + public Animal(Long id, String name, String type, String habitat, Short version) { + this.id = id; + this.name = name; + this.type = type; + this.habitat = habitat; + this.version = version; + } + + public Long getId() { + return id; + } + public Animal setId(Long id) { this.id = id; return this; } + public String getName() { + return name; + } + public Animal setName(String name) { this.name = name; return this; } + public String getType() { + return type; + } + public Animal setType(String type) { this.type = type; return this; } + public String getHabitat() { + return habitat; + } + public Animal setHabitat(String habitat) { this.habitat = habitat; return this; } - public void setCreated(LocalDateTime created) { - this.created = created; + public Short getVersion() { + return version; } public Animal setVersion(Short version) { diff --git a/jpa/keyset-pagination/boot-data-window-pagination/src/main/java/com/example/keysetpagination/entities/Auditable.java b/jpa/keyset-pagination/boot-data-window-pagination/src/main/java/com/example/keysetpagination/entities/Auditable.java index 9dc799731..71868c101 100644 --- a/jpa/keyset-pagination/boot-data-window-pagination/src/main/java/com/example/keysetpagination/entities/Auditable.java +++ b/jpa/keyset-pagination/boot-data-window-pagination/src/main/java/com/example/keysetpagination/entities/Auditable.java @@ -4,18 +4,22 @@ import jakarta.persistence.EntityListeners; import jakarta.persistence.MappedSuperclass; import java.time.LocalDateTime; -import lombok.Getter; -import lombok.Setter; import org.springframework.data.annotation.CreatedDate; import org.springframework.data.jpa.domain.support.AuditingEntityListener; @EntityListeners(AuditingEntityListener.class) @MappedSuperclass -@Setter -@Getter public abstract class Auditable { @CreatedDate @Column(nullable = false, updatable = false) protected LocalDateTime created; + + public LocalDateTime getCreated() { + return created; + } + + public void setCreated(LocalDateTime created) { + this.created = created; + } } diff --git a/jpa/keyset-pagination/boot-data-window-pagination/src/main/java/com/example/keysetpagination/model/query/SearchCriteria.java b/jpa/keyset-pagination/boot-data-window-pagination/src/main/java/com/example/keysetpagination/model/query/SearchCriteria.java index 9cbeb73c5..83b9504c1 100644 --- a/jpa/keyset-pagination/boot-data-window-pagination/src/main/java/com/example/keysetpagination/model/query/SearchCriteria.java +++ b/jpa/keyset-pagination/boot-data-window-pagination/src/main/java/com/example/keysetpagination/model/query/SearchCriteria.java @@ -5,15 +5,7 @@ import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Size; import java.util.List; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -@Setter -@Getter -@AllArgsConstructor -@NoArgsConstructor + public class SearchCriteria { @NotNull(message = "Operator cannot be null") private QueryOperator queryOperator; @@ -24,4 +16,36 @@ public class SearchCriteria { @NotNull(message = "Values list cannot be null") @Size(min = 1, message = "Values list cannot be empty") @Valid private List values; + + public SearchCriteria() {} + + public SearchCriteria(QueryOperator queryOperator, String field, List values) { + this.queryOperator = queryOperator; + this.field = field; + this.values = values; + } + + public QueryOperator getQueryOperator() { + return queryOperator; + } + + public void setQueryOperator(QueryOperator queryOperator) { + this.queryOperator = queryOperator; + } + + public String getField() { + return field; + } + + public void setField(String field) { + this.field = field; + } + + public List getValues() { + return values; + } + + public void setValues(List values) { + this.values = values; + } } diff --git a/jpa/keyset-pagination/boot-data-window-pagination/src/main/java/com/example/keysetpagination/web/controllers/AnimalController.java b/jpa/keyset-pagination/boot-data-window-pagination/src/main/java/com/example/keysetpagination/web/controllers/AnimalController.java index 72bf4ea75..3dc2c5f1a 100644 --- a/jpa/keyset-pagination/boot-data-window-pagination/src/main/java/com/example/keysetpagination/web/controllers/AnimalController.java +++ b/jpa/keyset-pagination/boot-data-window-pagination/src/main/java/com/example/keysetpagination/web/controllers/AnimalController.java @@ -17,7 +17,6 @@ import jakarta.validation.constraints.Min; import java.net.URI; import java.util.List; -import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Window; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; @@ -34,12 +33,15 @@ @RestController @RequestMapping("/api/animals") -@RequiredArgsConstructor @Validated class AnimalController { private final AnimalService animalService; + public AnimalController(AnimalService animalService) { + this.animalService = animalService; + } + @GetMapping PagedResult getAllAnimals( @RequestParam(value = "pageNo", defaultValue = AppConstants.DEFAULT_PAGE_NUMBER, required = false)