From 2f7a5db4c23580f6a60d4ceb7a27e35bcde31052 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Wed, 18 Dec 2024 15:02:37 +0200 Subject: [PATCH] Simplify as JpaFilterConverter now only has one helper method --- .../data/jpa/CrudRepositoryService.java | 13 ------------ .../spring/data/jpa/JpaFilterConverter.java | 4 ++-- .../data/jpa/ListRepositoryService.java | 20 ++----------------- 3 files changed, 4 insertions(+), 33 deletions(-) diff --git a/vaadin-spring/src/main/java/com/vaadin/flow/spring/data/jpa/CrudRepositoryService.java b/vaadin-spring/src/main/java/com/vaadin/flow/spring/data/jpa/CrudRepositoryService.java index 901074f62e4..b5803d50d12 100644 --- a/vaadin-spring/src/main/java/com/vaadin/flow/spring/data/jpa/CrudRepositoryService.java +++ b/vaadin-spring/src/main/java/com/vaadin/flow/spring/data/jpa/CrudRepositoryService.java @@ -15,19 +15,6 @@ public class CrudRepositoryService & JpaSpecificationExecutor> extends ListRepositoryService implements CrudService { - /** - * Creates the service using the given repository and filter converter. - * - * @param repository - * the JPA repository - * @param jpaFilterConverter - * the JPA filter converter - */ - public CrudRepositoryService(R repository, - JpaFilterConverter jpaFilterConverter) { - super(repository, jpaFilterConverter); - } - /** * Creates the service using the given repository. * diff --git a/vaadin-spring/src/main/java/com/vaadin/flow/spring/data/jpa/JpaFilterConverter.java b/vaadin-spring/src/main/java/com/vaadin/flow/spring/data/jpa/JpaFilterConverter.java index c4c0ad9f9d6..49cff5ccc08 100644 --- a/vaadin-spring/src/main/java/com/vaadin/flow/spring/data/jpa/JpaFilterConverter.java +++ b/vaadin-spring/src/main/java/com/vaadin/flow/spring/data/jpa/JpaFilterConverter.java @@ -8,7 +8,7 @@ import com.vaadin.flow.spring.data.filter.PropertyStringFilter; /** - * Utility class for converting Hilla {@link Filter} specifications into JPA + * Utility class for converting {@link Filter} specifications into JPA * filter specifications. This class can be used to implement filtering for * custom {@link com.vaadin.flow.spring.data.ListService} or * {@link com.vaadin.flow.spring.data.CrudService} implementations that use JPA @@ -33,7 +33,7 @@ public class JpaFilterConverter { * the entity class * @return a JPA filter specification for the given filter */ - public Specification toSpec(Filter rawFilter, Class entity) { + public static Specification toSpec(Filter rawFilter, Class entity) { if (rawFilter == null) { return Specification.anyOf(); } diff --git a/vaadin-spring/src/main/java/com/vaadin/flow/spring/data/jpa/ListRepositoryService.java b/vaadin-spring/src/main/java/com/vaadin/flow/spring/data/jpa/ListRepositoryService.java index fa48eeb2dd9..251e90fd9be 100644 --- a/vaadin-spring/src/main/java/com/vaadin/flow/spring/data/jpa/ListRepositoryService.java +++ b/vaadin-spring/src/main/java/com/vaadin/flow/spring/data/jpa/ListRepositoryService.java @@ -22,8 +22,6 @@ public class ListRepositoryService & JpaSpecificationExecutor> implements ListService, GetService, CountService { - private final JpaFilterConverter jpaFilterConverter; - private final R repository; private final Class entityClass; @@ -33,26 +31,12 @@ public class ListRepositoryService & JpaS * * @param repository * the JPA repository - * @param jpaFilterConverter - * the JPA filter converter */ - public ListRepositoryService(R repository, - JpaFilterConverter jpaFilterConverter) { - this.jpaFilterConverter = jpaFilterConverter; + public ListRepositoryService(R repository) { this.repository = repository; this.entityClass = resolveEntityClass(); } - /** - * Creates the service using the given repository. - * - * @param repository - * the JPA repository - */ - public ListRepositoryService(R repository) { - this(repository, new JpaFilterConverter()); - } - /** * Accessor for the repository instance. * @@ -98,7 +82,7 @@ public long count(@Nullable Filter filter) { * @return a JPA specification */ protected Specification toSpec(@Nullable Filter filter) { - return jpaFilterConverter.toSpec(filter, entityClass); + return JpaFilterConverter.toSpec(filter, entityClass); } @SuppressWarnings("unchecked")