From df6ca3de37ed2573b4d6b7f187eefebfddac43db Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Mon, 4 Nov 2024 14:30:37 +0100 Subject: [PATCH] Polishing. Add missing Override annotations, consistently use literal tags for boolean values. --- .../data/auditing/AuditingHandlerSupport.java | 4 ++-- .../org/springframework/data/domain/Window.java | 6 +++--- .../data/expression/ValueExpression.java | 2 +- .../org/springframework/data/mapping/Alias.java | 2 +- .../data/mapping/PersistentEntity.java | 2 +- .../AnnotationBasedPersistentProperty.java | 4 ++-- .../data/mapping/model/KotlinValueUtils.java | 2 +- .../PersistentEntityParameterValueProvider.java | 17 ++++++++--------- .../data/projection/EntityProjection.java | 4 ++-- .../EntityProjectionIntrospector.java | 4 ++-- .../PropertiesBasedNamedQueriesFactoryBean.java | 2 +- .../core/RepositoryMethodContextHolder.java | 2 +- .../repository/core/support/MethodLookup.java | 4 ++-- .../springframework/data/spel/spi/Function.java | 4 ++-- .../data/util/KotlinReflectionUtils.java | 4 ++-- .../springframework/data/util/Predicates.java | 8 ++++---- .../OffsetScrollPositionArgumentResolver.java | 2 +- .../data/web/PageableArgumentResolver.java | 2 +- .../data/web/SortArgumentResolver.java | 2 +- .../data/auditing/AuditingHandlerUnitTests.java | 2 +- 20 files changed, 39 insertions(+), 40 deletions(-) diff --git a/src/main/java/org/springframework/data/auditing/AuditingHandlerSupport.java b/src/main/java/org/springframework/data/auditing/AuditingHandlerSupport.java index 489a2e6457..750f3e9b44 100644 --- a/src/main/java/org/springframework/data/auditing/AuditingHandlerSupport.java +++ b/src/main/java/org/springframework/data/auditing/AuditingHandlerSupport.java @@ -61,7 +61,7 @@ public AuditingHandlerSupport(PersistentEntities entities) { /** * Setter do determine if {@link Auditable#setCreatedDate(TemporalAccessor)}} and * {@link Auditable#setLastModifiedDate(TemporalAccessor)} shall be filled with the current Java time. Defaults to - * {@code true}. One might set this to {@code false} to use database features to set entity time. + * {@literal true}. One might set this to {@literal false} to use database features to set entity time. * * @param dateTimeForNow the dateTimeForNow to set */ @@ -71,7 +71,7 @@ public void setDateTimeForNow(boolean dateTimeForNow) { /** * Set this to true if you want to treat entity creation as modification and thus setting the current date as - * modification date during creation, too. Defaults to {@code true}. + * modification date during creation, too. Defaults to {@literal true}. * * @param modifyOnCreation if modification information shall be set on creation, too */ diff --git a/src/main/java/org/springframework/data/domain/Window.java b/src/main/java/org/springframework/data/domain/Window.java index d5c220b27c..9303bed20a 100644 --- a/src/main/java/org/springframework/data/domain/Window.java +++ b/src/main/java/org/springframework/data/domain/Window.java @@ -68,9 +68,9 @@ static Window from(List items, IntFunction p int size(); /** - * Returns {@code true} if this window contains no elements. + * Returns {@literal true} if this window contains no elements. * - * @return {@code true} if this window contains no elements + * @return {@literal true} if this window contains no elements */ @Override boolean isEmpty(); @@ -102,7 +102,7 @@ default boolean isLast() { * Returns whether the underlying scroll mechanism can provide a {@link ScrollPosition} at {@code index}. * * @param index - * @return {@code true} if a {@link ScrollPosition} can be created; {@code false} otherwise. + * @return {@literal true} if a {@link ScrollPosition} can be created; {@literal false} otherwise. * @see #positionAt(int) */ default boolean hasPosition(int index) { diff --git a/src/main/java/org/springframework/data/expression/ValueExpression.java b/src/main/java/org/springframework/data/expression/ValueExpression.java index 7ad6ad4d26..b5e701d468 100644 --- a/src/main/java/org/springframework/data/expression/ValueExpression.java +++ b/src/main/java/org/springframework/data/expression/ValueExpression.java @@ -48,7 +48,7 @@ default ExpressionDependencies getExpressionDependencies() { /** * Returns whether the expression is a literal expression (that doesn't actually require evaluation). * - * @return {@code true} if the expression is a literal expression; {@code false} if the expression can yield a + * @return {@literal true} if the expression is a literal expression; {@literal false} if the expression can yield a * different result upon {@link #evaluate(ValueEvaluationContext) evaluation}. */ boolean isLiteral(); diff --git a/src/main/java/org/springframework/data/mapping/Alias.java b/src/main/java/org/springframework/data/mapping/Alias.java index 7d581285b6..fb488af038 100644 --- a/src/main/java/org/springframework/data/mapping/Alias.java +++ b/src/main/java/org/springframework/data/mapping/Alias.java @@ -22,7 +22,7 @@ /** * A container object which may or may not contain a type alias value. If a value is present, {@code isPresent()} will - * return {@code true} and {@link #getValue()} will return the value. + * return {@literal true} and {@link #getValue()} will return the value. *

* Additional methods that depend on the presence or absence of a contained value are provided, such as * {@link #hasValue(Object)} or {@link #isPresent()} diff --git a/src/main/java/org/springframework/data/mapping/PersistentEntity.java b/src/main/java/org/springframework/data/mapping/PersistentEntity.java index 1b910eb99d..a3536533d8 100644 --- a/src/main/java/org/springframework/data/mapping/PersistentEntity.java +++ b/src/main/java/org/springframework/data/mapping/PersistentEntity.java @@ -229,7 +229,7 @@ default P getPersistentProperty(Class annotationType) { * Returns whether the property is transient. * * @param property name of the property. - * @return {@code true} if the property is transient. Applies only for existing properties. {@code false} if the + * @return {@literal true} if the property is transient. Applies only for existing properties. {@literal false} if the * property does not exist or is not transient. * @since 3.3 */ diff --git a/src/main/java/org/springframework/data/mapping/model/AnnotationBasedPersistentProperty.java b/src/main/java/org/springframework/data/mapping/model/AnnotationBasedPersistentProperty.java index 4bd60cc391..6e122de724 100644 --- a/src/main/java/org/springframework/data/mapping/model/AnnotationBasedPersistentProperty.java +++ b/src/main/java/org/springframework/data/mapping/model/AnnotationBasedPersistentProperty.java @@ -264,10 +264,10 @@ public A findPropertyOrOwnerAnnotation(Class annotatio } /** - * Returns whether the property carries the an annotation of the given type. + * Returns whether the property carries the annotation of the given type. * * @param annotationType the annotation type to look up. - * @return + * @return {@literal true} if the annotation is present, {@literal false} otherwise. */ @Override public boolean isAnnotationPresent(Class annotationType) { diff --git a/src/main/java/org/springframework/data/mapping/model/KotlinValueUtils.java b/src/main/java/org/springframework/data/mapping/model/KotlinValueUtils.java index f2fba6358e..153060c2ca 100644 --- a/src/main/java/org/springframework/data/mapping/model/KotlinValueUtils.java +++ b/src/main/java/org/springframework/data/mapping/model/KotlinValueUtils.java @@ -348,7 +348,7 @@ public Class getParameterType() { } /** - * @return {@code true} if the value hierarchy applies boxing. + * @return {@literal true} if the value hierarchy applies boxing. */ public boolean appliesBoxing() { return applyBoxing; diff --git a/src/main/java/org/springframework/data/mapping/model/PersistentEntityParameterValueProvider.java b/src/main/java/org/springframework/data/mapping/model/PersistentEntityParameterValueProvider.java index 0770e8c1ba..2093f8e4ac 100644 --- a/src/main/java/org/springframework/data/mapping/model/PersistentEntityParameterValueProvider.java +++ b/src/main/java/org/springframework/data/mapping/model/PersistentEntityParameterValueProvider.java @@ -26,9 +26,7 @@ /** * {@link ParameterValueProvider} based on a {@link PersistentEntity} to use a {@link PropertyValueProvider} to look up - * the value of the property referenced by the given {@link Parameter}. Additionally, a - * {@link DefaultSpELExpressionEvaluator} can be configured to get property value resolution trumped by a SpEL - * expression evaluation. + * the value of the property referenced by the given {@link Parameter}. * * @author Oliver Gierke * @author Johannes Englmeier @@ -42,18 +40,13 @@ public class PersistentEntityParameterValueProvider

entity, PropertyValueProvider

provider, - Object parent) { + @Nullable Object parent) { this.entity = entity; this.provider = provider; this.parent = parent; } @Override - @Nullable - private static Object getTransientDefault(Class parameterType) { - return parameterType.isPrimitive() ? ReflectionUtils.getPrimitiveDefault(parameterType) : null; - } - @Nullable @SuppressWarnings("unchecked") public T getParameterValue(Parameter parameter) { @@ -82,4 +75,10 @@ public T getParameterValue(Parameter parameter) { return provider.getPropertyValue(property); } + + @Nullable + private static Object getTransientDefault(Class parameterType) { + return parameterType.isPrimitive() ? ReflectionUtils.getPrimitiveDefault(parameterType) : null; + } + } diff --git a/src/main/java/org/springframework/data/projection/EntityProjection.java b/src/main/java/org/springframework/data/projection/EntityProjection.java index f3941182e2..60fd4058a0 100644 --- a/src/main/java/org/springframework/data/projection/EntityProjection.java +++ b/src/main/java/org/springframework/data/projection/EntityProjection.java @@ -158,14 +158,14 @@ public TypeInformation getActualDomainType() { } /** - * @return {@code true} if the {@link #getMappedType()} is a projection. + * @return {@literal true} if the {@link #getMappedType()} is a projection. */ public boolean isProjection() { return projection; } /** - * @return {@code true} if the {@link #getMappedType()} is a closed projection. + * @return {@literal true} if the {@link #getMappedType()} is a closed projection. */ public boolean isClosedProjection() { return isProjection() diff --git a/src/main/java/org/springframework/data/projection/EntityProjectionIntrospector.java b/src/main/java/org/springframework/data/projection/EntityProjectionIntrospector.java index 88335a22dd..a0396bc020 100644 --- a/src/main/java/org/springframework/data/projection/EntityProjectionIntrospector.java +++ b/src/main/java/org/springframework/data/projection/EntityProjectionIntrospector.java @@ -222,13 +222,13 @@ public interface ProjectionPredicate { * * @param target the target type. * @param underlyingType the underlying type. - * @return {@code true} if the input argument matches the predicate, otherwise {@code false}. + * @return {@literal true} if the input argument matches the predicate, otherwise {@literal false}. */ boolean test(Class target, Class underlyingType); /** * Return a composed predicate that represents a short-circuiting logical AND of this predicate and another. When - * evaluating the composed predicate, if this predicate is {@code false}, then the {@code other} predicate is not + * evaluating the composed predicate, if this predicate is {@literal false}, then the {@code other} predicate is not * evaluated. *

* Any exceptions thrown during evaluation of either predicate are relayed to the caller; if evaluation of this diff --git a/src/main/java/org/springframework/data/repository/config/PropertiesBasedNamedQueriesFactoryBean.java b/src/main/java/org/springframework/data/repository/config/PropertiesBasedNamedQueriesFactoryBean.java index 02f3f16901..7e7b7e28d5 100644 --- a/src/main/java/org/springframework/data/repository/config/PropertiesBasedNamedQueriesFactoryBean.java +++ b/src/main/java/org/springframework/data/repository/config/PropertiesBasedNamedQueriesFactoryBean.java @@ -47,7 +47,7 @@ public class PropertiesBasedNamedQueriesFactoryBean extends PropertiesLoaderSupp * Set whether a shared singleton {@code PropertiesBasedNamedQueries} instance should be created, or rather a new * {@code PropertiesBasedNamedQueries} instance on each request. *

- * Default is {@code true} (a shared singleton). + * Default is {@literal true} (a shared singleton). */ public void setSingleton(boolean singleton) { this.singleton = singleton; diff --git a/src/main/java/org/springframework/data/repository/core/RepositoryMethodContextHolder.java b/src/main/java/org/springframework/data/repository/core/RepositoryMethodContextHolder.java index bc57f152f7..b52ee50e38 100644 --- a/src/main/java/org/springframework/data/repository/core/RepositoryMethodContextHolder.java +++ b/src/main/java/org/springframework/data/repository/core/RepositoryMethodContextHolder.java @@ -34,7 +34,7 @@ public class RepositoryMethodContextHolder { /** * ThreadLocal holder for repository method associated with this thread. Will contain {@code null} unless the - * "exposeMetadata" property on the controlling repository factory configuration has been set to {@code true}. + * "exposeMetadata" property on the controlling repository factory configuration has been set to {@literal true}. */ private static final ThreadLocal currentMethod = new NamedThreadLocal<>( "Current Repository Method"); diff --git a/src/main/java/org/springframework/data/repository/core/support/MethodLookup.java b/src/main/java/org/springframework/data/repository/core/support/MethodLookup.java index 6b1213e9c9..c0a5fe0c94 100644 --- a/src/main/java/org/springframework/data/repository/core/support/MethodLookup.java +++ b/src/main/java/org/springframework/data/repository/core/support/MethodLookup.java @@ -49,8 +49,8 @@ public interface MethodLookup { /** * Returns a composed {@link MethodLookup} that represents a concatenation of this predicate and another. When - * evaluating the composed method lookup, if this lookup evaluates {@code true}, then the {@code other} method lookup - * is not evaluated. + * evaluating the composed method lookup, if this lookup evaluates {@literal true}, then the {@code other} method + * lookup is not evaluated. * * @param other must not be {@literal null}. * @return the composed {@link MethodLookup}. diff --git a/src/main/java/org/springframework/data/spel/spi/Function.java b/src/main/java/org/springframework/data/spel/spi/Function.java index d315c84b18..0d5a02fd61 100644 --- a/src/main/java/org/springframework/data/spel/spi/Function.java +++ b/src/main/java/org/springframework/data/spel/spi/Function.java @@ -152,7 +152,7 @@ public int getParameterCount() { * Checks if the encapsulated method has exactly the argument types as those passed as an argument. * * @param argumentTypes a list of {@link TypeDescriptor}s to compare with the argument types of the method - * @return {@code true} if the types are equal, {@code false} otherwise. + * @return {@literal true} if the types are equal, {@literal false} otherwise. */ public boolean supportsExact(List argumentTypes) { return ParameterTypes.of(argumentTypes).exactlyMatchParametersOf(method); @@ -162,7 +162,7 @@ public boolean supportsExact(List argumentTypes) { * Checks whether this {@code Function} has the same signature as another {@code Function}. * * @param other the {@code Function} to compare {@code this} with. - * @return {@code true} if name and argument list are the same. + * @return {@literal true} if name and argument list are the same. */ public boolean isSignatureEqual(Function other) { diff --git a/src/main/java/org/springframework/data/util/KotlinReflectionUtils.java b/src/main/java/org/springframework/data/util/KotlinReflectionUtils.java index f958bdc520..f6ad333f5d 100644 --- a/src/main/java/org/springframework/data/util/KotlinReflectionUtils.java +++ b/src/main/java/org/springframework/data/util/KotlinReflectionUtils.java @@ -136,7 +136,7 @@ public static Class getReturnType(Method method) { * Returns whether the given {@link KType} is a {@link KClass#isValue() value} class. * * @param type the kotlin type to inspect. - * @return {@code true} the type is a value class. + * @return {@literal true} the type is a value class. * @since 3.2 */ public static boolean isValueClass(KType type) { @@ -148,7 +148,7 @@ public static boolean isValueClass(KType type) { * Returns whether the given class makes uses Kotlin {@link KClass#isValue() value} classes. * * @param type the kotlin type to inspect. - * @return {@code true} when at least one property uses Kotlin value classes. + * @return {@literal true} when at least one property uses Kotlin value classes. * @since 3.2 */ public static boolean hasValueClassProperty(Class type) { diff --git a/src/main/java/org/springframework/data/util/Predicates.java b/src/main/java/org/springframework/data/util/Predicates.java index ff50758c36..e9afbe295c 100644 --- a/src/main/java/org/springframework/data/util/Predicates.java +++ b/src/main/java/org/springframework/data/util/Predicates.java @@ -52,18 +52,18 @@ public interface Predicates { Predicate IS_BRIDGE_METHOD = Method::isBridge; /** - * A {@link Predicate} that yields always {@code true}. + * A {@link Predicate} that yields always {@literal true}. * - * @return a {@link Predicate} that yields always {@code true}. + * @return a {@link Predicate} that yields always {@literal true}. */ static Predicate isTrue() { return t -> true; } /** - * A {@link Predicate} that yields always {@code false}. + * A {@link Predicate} that yields always {@literal false}. * - * @return a {@link Predicate} that yields always {@code false}. + * @return a {@link Predicate} that yields always {@literal false}. */ static Predicate isFalse() { return t -> false; diff --git a/src/main/java/org/springframework/data/web/OffsetScrollPositionArgumentResolver.java b/src/main/java/org/springframework/data/web/OffsetScrollPositionArgumentResolver.java index 6812251416..e6dc1e3a29 100644 --- a/src/main/java/org/springframework/data/web/OffsetScrollPositionArgumentResolver.java +++ b/src/main/java/org/springframework/data/web/OffsetScrollPositionArgumentResolver.java @@ -42,7 +42,7 @@ public interface OffsetScrollPositionArgumentResolver extends HandlerMethodArgum * wrapped arguments in {@link java.util.Optional}. * * @param parameter the method parameter to resolve. This parameter must have previously been passed to - * {@link #supportsParameter} which must have returned {@code true}. + * {@link #supportsParameter} which must have returned {@literal true}. * @param mavContainer the ModelAndViewContainer for the current request * @param webRequest the current request * @param binderFactory a factory for creating {@link WebDataBinder} instances diff --git a/src/main/java/org/springframework/data/web/PageableArgumentResolver.java b/src/main/java/org/springframework/data/web/PageableArgumentResolver.java index 32e1e15793..97aa5c93e6 100644 --- a/src/main/java/org/springframework/data/web/PageableArgumentResolver.java +++ b/src/main/java/org/springframework/data/web/PageableArgumentResolver.java @@ -40,7 +40,7 @@ public interface PageableArgumentResolver extends HandlerMethodArgumentResolver * Resolves a {@link Pageable} method parameter into an argument value from a given request. * * @param parameter the method parameter to resolve. This parameter must have previously been passed to - * {@link #supportsParameter} which must have returned {@code true}. + * {@link #supportsParameter} which must have returned {@literal true}. * @param mavContainer the ModelAndViewContainer for the current request * @param webRequest the current request * @param binderFactory a factory for creating {@link WebDataBinder} instances diff --git a/src/main/java/org/springframework/data/web/SortArgumentResolver.java b/src/main/java/org/springframework/data/web/SortArgumentResolver.java index bba155f8af..cff7aeffad 100644 --- a/src/main/java/org/springframework/data/web/SortArgumentResolver.java +++ b/src/main/java/org/springframework/data/web/SortArgumentResolver.java @@ -40,7 +40,7 @@ public interface SortArgumentResolver extends HandlerMethodArgumentResolver { * Resolves a {@link Sort} method parameter into an argument value from a given request. * * @param parameter the method parameter to resolve. This parameter must have previously been passed to - * {@link #supportsParameter} which must have returned {@code true}. + * {@link #supportsParameter} which must have returned {@literal true}. * @param mavContainer the ModelAndViewContainer for the current request * @param webRequest the current request * @param binderFactory a factory for creating {@link WebDataBinder} instances diff --git a/src/test/java/org/springframework/data/auditing/AuditingHandlerUnitTests.java b/src/test/java/org/springframework/data/auditing/AuditingHandlerUnitTests.java index 46c1c9abf5..c8786f2809 100755 --- a/src/test/java/org/springframework/data/auditing/AuditingHandlerUnitTests.java +++ b/src/test/java/org/springframework/data/auditing/AuditingHandlerUnitTests.java @@ -96,7 +96,7 @@ void setsAuditorIfConfigured() { } /** - * Checks that the advice does not set modification information on creation if the falg is set to {@code false}. + * Checks that the advice does not set modification information on creation if the falg is set to {@literal false}. */ @Test void honoursModifiedOnCreationFlag() {