From 29f16ab09f12c24d4e6ef1ce53ef91d6473d0772 Mon Sep 17 00:00:00 2001 From: Hyeon Sung Date: Mon, 2 Dec 2024 16:50:11 +0900 Subject: [PATCH] Extract repeated string literals in `SimpleJpaRepository` to constants. Closes #3698 --- .../support/SimpleJpaRepository.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/support/SimpleJpaRepository.java b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/support/SimpleJpaRepository.java index d170a8acf..f40821ab3 100644 --- a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/support/SimpleJpaRepository.java +++ b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/support/SimpleJpaRepository.java @@ -100,7 +100,11 @@ public class SimpleJpaRepository implements JpaRepositoryImplementation entityInformation; private final EntityManager entityManager; @@ -190,7 +194,7 @@ public class SimpleJpaRepository implements JpaRepositoryImplementation implements JpaRepositoryImplementation R findBy(Specification spec, Function, R> queryFunction) { - Assert.notNull(spec, "Specification must not be null"); - Assert.notNull(queryFunction, "Query function must not be null"); + Assert.notNull(spec, SPECIFICATION_MUST_NOT_BE_NULL); + Assert.notNull(queryFunction, QUERY_FUNCTION_MUST_NOT_BE_NULL); return doFindBy(spec, getDomainClass(), queryFunction); } @@ -504,8 +508,8 @@ public class SimpleJpaRepository implements JpaRepositoryImplementation R doFindBy(Specification spec, Class domainClass, Function, R> queryFunction) { - Assert.notNull(spec, "Specification must not be null"); - Assert.notNull(queryFunction, "Query function must not be null"); + Assert.notNull(spec, SPECIFICATION_MUST_NOT_BE_NULL); + Assert.notNull(queryFunction, QUERY_FUNCTION_MUST_NOT_BE_NULL); ScrollQueryFactory scrollFunction = (sort, scrollPosition) -> { @@ -594,8 +598,8 @@ public class SimpleJpaRepository implements JpaRepositoryImplementation R findBy(Example example, Function, R> queryFunction) { - Assert.notNull(example, "Example must not be null"); - Assert.notNull(queryFunction, "Query function must not be null"); + Assert.notNull(example, EXAMPLE_MUST_NOT_BE_NULL); + Assert.notNull(queryFunction, QUERY_FUNCTION_MUST_NOT_BE_NULL); ExampleSpecification spec = new ExampleSpecification<>(example, escapeCharacter); Class probeType = example.getProbeType(); @@ -622,7 +626,7 @@ public class SimpleJpaRepository implements JpaRepositoryImplementation S save(S entity) { - Assert.notNull(entity, "Entity must not be null"); + Assert.notNull(entity, ENTITY_MUST_NOT_BE_NULL); if (entityInformation.isNew(entity)) { entityManager.persist(entity); @@ -997,7 +1001,7 @@ public class SimpleJpaRepository implements JpaRepositoryImplementation example, EscapeCharacter escapeCharacter) { - Assert.notNull(example, "Example must not be null"); + Assert.notNull(example, EXAMPLE_MUST_NOT_BE_NULL); Assert.notNull(escapeCharacter, "EscapeCharacter must not be null"); this.example = example;