From 162dd835787dea87f70948264eb36529cb185702 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Thu, 4 Dec 2025 15:40:57 +0100 Subject: [PATCH] Polishing. Improve Javadoc. See #3423 --- .../support/RepositoryFactoryBeanSupport.java | 27 +++++++++------- .../support/RepositoryFactorySupport.java | 32 ++++++------------- .../repository/query/QueryLookupStrategy.java | 7 ++-- 3 files changed, 30 insertions(+), 36 deletions(-) diff --git a/src/main/java/org/springframework/data/repository/core/support/RepositoryFactoryBeanSupport.java b/src/main/java/org/springframework/data/repository/core/support/RepositoryFactoryBeanSupport.java index 66f29349b..2f505148a 100644 --- a/src/main/java/org/springframework/data/repository/core/support/RepositoryFactoryBeanSupport.java +++ b/src/main/java/org/springframework/data/repository/core/support/RepositoryFactoryBeanSupport.java @@ -122,8 +122,9 @@ public abstract class RepositoryFactoryBeanSupport, * retrieval via the {@code RepositoryMethodContext} class. This is useful if an advised object needs to obtain * repository information. *

- * Default is "false", in order to avoid unnecessary extra interception. This means that no guarantees are provided - * that {@code RepositoryMethodContext} access will work consistently within any method of the advised object. + * Default is {@code false}, in order to avoid unnecessary extra interception. This means that no guarantees are + * provided that {@code RepositoryMethodContext} access will work consistently within any method of the advised + * object. * * @since 3.4 */ @@ -134,16 +135,20 @@ public abstract class RepositoryFactoryBeanSupport, /** * Set the {@link QueryLookupStrategy.Key} to be used. * - * @param queryLookupStrategyKey + * @param queryLookupStrategyKey the lookup strategy key to be used. */ public void setQueryLookupStrategyKey(Key queryLookupStrategyKey) { this.queryLookupStrategyKey = queryLookupStrategyKey; } /** - * Setter to inject a custom repository implementation. + * Setter to provide a single a custom repository implementation. Single custom implementations are considered first + * when determining target method invocations routing. Single custom implementations were superseded by + * {@link RepositoryFragments} that provide a more flexible way to compose repository implementations from multiple + * fragments consisting of a fragment interface and its implementation. * - * @param customImplementation + * @param customImplementation the single custom implementation. + * @see #setRepositoryFragments(RepositoryFragments) */ public void setCustomImplementation(Object customImplementation) { this.customImplementation = customImplementation; @@ -153,7 +158,7 @@ public abstract class RepositoryFactoryBeanSupport, * Setter to inject repository fragments. This method is additive and will add another {@link RepositoryFragments} to * the already existing list of {@link RepositoryFragmentsFunction}. * - * @param repositoryFragments + * @param repositoryFragments the repository fragments to be used. */ public void setRepositoryFragments(RepositoryFragments repositoryFragments) { setRepositoryFragmentsFunction(RepositoryFragmentsFunction.just(repositoryFragments)); @@ -163,7 +168,7 @@ public abstract class RepositoryFactoryBeanSupport, * Setter to inject repository fragments. This method is additive and will add another {@link RepositoryFragments} to * the already existing list of {@link RepositoryFragmentsFunction}. * - * @param fragmentsFunction + * @param fragmentsFunction function to derive additional repository fragments. * @since 4.0 */ public void setRepositoryFragmentsFunction(RepositoryFragmentsFunction fragmentsFunction) { @@ -173,7 +178,7 @@ public abstract class RepositoryFactoryBeanSupport, /** * Setter to inject a {@link NamedQueries} instance. * - * @param namedQueries the namedQueries to set + * @param namedQueries the namedQueries to set. */ public void setNamedQueries(NamedQueries namedQueries) { this.namedQueries = namedQueries; @@ -183,7 +188,7 @@ public abstract class RepositoryFactoryBeanSupport, * Configures the {@link MappingContext} to be used to lookup {@link PersistentEntity} instances for * {@link #getPersistentEntity()}. * - * @param mappingContext + * @param mappingContext mapping context to be used. */ protected void setMappingContext(MappingContext mappingContext) { this.mappingContext = mappingContext; @@ -301,14 +306,14 @@ public abstract class RepositoryFactoryBeanSupport, return repositoryInterface; } - RepositoryFactorySupport getRequiredFactory() { + private RepositoryFactorySupport getRequiredFactory() { Assert.state(factory != null, "RepositoryFactory is not initialized"); return factory; } - RepositoryMetadata getRequiredRepositoryMetadata() { + private RepositoryMetadata getRequiredRepositoryMetadata() { Assert.state(repositoryMetadata != null, "RepositoryMetadata is not initialized"); diff --git a/src/main/java/org/springframework/data/repository/core/support/RepositoryFactorySupport.java b/src/main/java/org/springframework/data/repository/core/support/RepositoryFactorySupport.java index c90f90552..bd7e95eb4 100644 --- a/src/main/java/org/springframework/data/repository/core/support/RepositoryFactorySupport.java +++ b/src/main/java/org/springframework/data/repository/core/support/RepositoryFactorySupport.java @@ -144,7 +144,7 @@ public abstract class RepositoryFactorySupport * retrieval via the {@code RepositoryMethodContext} class. This is useful if an advised object needs to obtain * repository information. *

- * Default is {@literal "false"}, in order to avoid unnecessary extra interception. This means that no guarantees are + * Default is {@literal false}, in order to avoid unnecessary extra interception. This means that no guarantees are * provided that {@code RepositoryMethodContext} access will work consistently within any method of the advised * object. *

@@ -304,7 +304,7 @@ public abstract class RepositoryFactorySupport * @return the implemented repository interface. * @since 2.0 */ - @SuppressWarnings({ "unchecked", "deprecation" }) + @SuppressWarnings({ "unchecked", "resource" }) public T getRepository(Class repositoryInterface, RepositoryFragments fragments) { if (logger.isDebugEnabled()) { @@ -484,10 +484,6 @@ public abstract class RepositoryFactorySupport * fragments hash code. In a typical Spring scenario, that shouldn't impose issues as one repository factory produces * only a single repository instance for one repository interface. Things might be different when using various * fragments for the same repository interface. - * - * @param metadata - * @param fragments - * @return */ private RepositoryStub getRepositoryStub(RepositoryMetadata metadata, RepositoryFragments fragments) { @@ -549,10 +545,11 @@ public abstract class RepositoryFactorySupport } /** - * Create a repository instance as backing for the query proxy. + * Create a instance of the repository base class providing store-specific built-in repository functionality of a + * typical {@code CrudRepository}. * - * @param metadata - * @return + * @param metadata repository metadata. + * @return object implementing the repository base functionality. */ protected abstract Object getTargetRepository(RepositoryInformation metadata); @@ -560,8 +557,8 @@ public abstract class RepositoryFactorySupport * Returns the base class backing the actual repository instance. Make sure * {@link #getTargetRepository(RepositoryInformation)} returns an instance of this class. * - * @param metadata - * @return + * @param metadata repository metadata. + * @return the repository base class. */ protected abstract Class getRepositoryBaseClass(RepositoryMetadata metadata); @@ -580,9 +577,6 @@ public abstract class RepositoryFactorySupport /** * Validates the given repository interface as well as the given custom implementation. - * - * @param repositoryInformation - * @param composition */ private void validate(RepositoryInformation repositoryInformation, RepositoryComposition composition) { @@ -598,10 +592,6 @@ public abstract class RepositoryFactorySupport /** * Creates a repository of the repository base class defined in the given {@link RepositoryInformation} using * reflection. - * - * @param information - * @param constructorArguments - * @return */ protected final R getTargetRepositoryViaReflection(RepositoryInformation information, Object... constructorArguments) { @@ -616,10 +606,6 @@ public abstract class RepositoryFactorySupport *

* Note that this method tries to set the constructor accessible if given a non-accessible (that is, non-public) * constructor, and supports Kotlin classes with optional parameters and default values. - * - * @param baseClass - * @param constructorArguments - * @return * @since 2.6 */ @SuppressWarnings("unchecked") @@ -664,7 +650,7 @@ public abstract class RepositoryFactorySupport * Checks if at least one {@link RepositoryFragment} indicates need to access to {@link RepositoryMetadata} by being * flagged with {@link RepositoryMetadataAccess}. * - * @param fragments + * @param fragments the fragments to intospect. * @return {@literal true} if access to metadata is required. */ private static boolean shouldExposeMetadata(RepositoryFragments fragments) { diff --git a/src/main/java/org/springframework/data/repository/query/QueryLookupStrategy.java b/src/main/java/org/springframework/data/repository/query/QueryLookupStrategy.java index c69d20869..a176b3fda 100644 --- a/src/main/java/org/springframework/data/repository/query/QueryLookupStrategy.java +++ b/src/main/java/org/springframework/data/repository/query/QueryLookupStrategy.java @@ -32,14 +32,17 @@ import org.springframework.util.StringUtils; */ public interface QueryLookupStrategy { - public static enum Key { + /** + * Enumeration of available query lookup strategies. + */ + enum Key { CREATE, USE_DECLARED_QUERY, CREATE_IF_NOT_FOUND; /** * Returns a strategy key from the given XML value. * - * @param xml + * @param xml value represented as XML value. * @return a strategy key from the given XML value */ public static @Nullable Key create(String xml) {