Polishing.

Use consistently domain type instead of introducing a new terminology to repository infrastructure.

Rename Kotlin variant of ParameterUnitTests to KParameterUnitTests to avoid duplicate classes.

See #2770
Original pull request: #2771
This commit is contained in:
Mark Paluch
2023-02-14 11:52:39 +01:00
parent 16e7e7c79b
commit f82a48454e
5 changed files with 32 additions and 29 deletions

View File

@@ -79,19 +79,20 @@ public class Parameter {
}
/**
* Creates a new {@link Parameter} for the given {@link MethodParameter} and aggregate {@link TypeInformation}.
* Creates a new {@link Parameter} for the given {@link MethodParameter} and domain {@link TypeInformation}.
*
* @param parameter must not be {@literal null}.
* @param aggregateType must not be {@literal null}.
* @param domainType must not be {@literal null}.
* @since 3.0.2
*/
protected Parameter(MethodParameter parameter, TypeInformation<?> aggregateType) {
protected Parameter(MethodParameter parameter, TypeInformation<?> domainType) {
Assert.notNull(parameter, "MethodParameter must not be null");
Assert.notNull(aggregateType, "TypeInformation must not be null!");
Assert.notNull(domainType, "TypeInformation must not be null!");
this.parameter = parameter;
this.parameterType = potentiallyUnwrapParameterType(parameter);
this.isDynamicProjectionParameter = isDynamicProjectionParameter(parameter, aggregateType);
this.isDynamicProjectionParameter = isDynamicProjectionParameter(parameter, domainType);
this.name = isSpecialParameterType(parameter.getParameterType()) ? Lazy.of(Optional.empty()) : Lazy.of(() -> {
Param annotation = parameter.getParameterAnnotation(Param.class);
return Optional.ofNullable(annotation == null ? parameter.getParameterName() : annotation.value());
@@ -218,10 +219,10 @@ public class Parameter {
* </code>
*
* @param parameter must not be {@literal null}.
* @param aggregateType the reference aggregate type, must not be {@literal null}.
* @param domainType the reference domain type, must not be {@literal null}.
* @return
*/
private static boolean isDynamicProjectionParameter(MethodParameter parameter, TypeInformation<?> aggregateType) {
private static boolean isDynamicProjectionParameter(MethodParameter parameter, TypeInformation<?> domainType) {
if (!parameter.getParameterType().equals(Class.class)) {
return false;
@@ -241,7 +242,7 @@ public class Parameter {
var unwrapped = QueryExecutionConverters.unwrapWrapperTypes(returnType);
var reactiveUnwrapped = ReactiveWrapperConverters.unwrapWrapperTypes(unwrapped);
if (aggregateType.isAssignableFrom(reactiveUnwrapped)) {
if (domainType.isAssignableFrom(reactiveUnwrapped)) {
return false;
}

View File

@@ -77,6 +77,7 @@ public abstract class Parameters<S extends Parameters<S, T>, T extends Parameter
*
* @param method must not be {@literal null}.
* @param parameterFactory must not be {@literal null}.
* @since 3.0.2
*/
protected Parameters(Method method, Function<MethodParameter, T> parameterFactory) {
@@ -176,7 +177,7 @@ public abstract class Parameters<S extends Parameters<S, T>, T extends Parameter
*
* @param parameter will never be {@literal null}.
* @return
* @deprecated since 3.1, in your extension, call {@link #Parameters(Method, ParameterFactory)} instead.
* @deprecated since 3.1, in your extension, call {@link #Parameters(Method, Function)} instead.
*/
@SuppressWarnings("unchecked")
@Deprecated(since = "3.1", forRemoval = true)

View File

@@ -69,12 +69,10 @@ public class QueryMethod {
Assert.notNull(metadata, "Repository metadata must not be null");
Assert.notNull(factory, "ProjectionFactory must not be null");
Parameters.TYPES.stream()
.filter(type -> getNumberOfOccurrences(method, type) > 1)
.findFirst().ifPresent(type -> {
throw new IllegalStateException(
String.format("Method must have only one argument of type %s; Offending method: %s",
type.getSimpleName(), method));
Parameters.TYPES.stream() //
.filter(type -> getNumberOfOccurrences(method, type) > 1).findFirst().ifPresent(type -> {
throw new IllegalStateException(String.format(
"Method must have only one argument of type %s; Offending method: %s", type.getSimpleName(), method));
});
this.method = method;
@@ -132,11 +130,12 @@ public class QueryMethod {
* Creates a {@link Parameters} instance.
*
* @param method must not be {@literal null}.
* @param aggregateType must not be {@literal null}.
* @param domainType must not be {@literal null}.
* @return must not return {@literal null}.
* @since 3.0.2
*/
protected Parameters<?, ?> createParameters(Method method, TypeInformation<?> aggregateType) {
return new DefaultParameters(method, aggregateType);
protected Parameters<?, ?> createParameters(Method method, TypeInformation<?> domainType) {
return new DefaultParameters(method, domainType);
}
/**