18
18
import java .lang .reflect .Method ;
19
19
import java .util .Collections ;
20
20
import java .util .Set ;
21
+ import java .util .function .Function ;
21
22
import java .util .function .Predicate ;
22
23
import java .util .stream .Stream ;
23
24
38
39
import org .springframework .data .util .ReactiveWrappers ;
39
40
import org .springframework .data .util .ReflectionUtils ;
40
41
import org .springframework .data .util .TypeInformation ;
42
+ import org .springframework .lang .Nullable ;
41
43
import org .springframework .util .Assert ;
42
44
43
45
/**
@@ -68,8 +70,26 @@ public class QueryMethod {
68
70
* @param method must not be {@literal null}.
69
71
* @param metadata must not be {@literal null}.
70
72
* @param factory must not be {@literal null}.
73
+ * @deprecated since 3.5, use {@link QueryMethod#QueryMethod(Method, RepositoryMetadata, ProjectionFactory, Function)}
74
+ * instead.
71
75
*/
76
+ @ Deprecated (since = "3.5" )
72
77
public QueryMethod (Method method , RepositoryMetadata metadata , ProjectionFactory factory ) {
78
+ this (method , metadata , factory , null );
79
+ }
80
+
81
+ /**
82
+ * Creates a new {@link QueryMethod} from the given parameters. Looks up the correct query to use for following
83
+ * invocations of the method given.
84
+ *
85
+ * @param method must not be {@literal null}.
86
+ * @param metadata must not be {@literal null}.
87
+ * @param factory must not be {@literal null}.
88
+ * @param parametersFunction must not be {@literal null}.
89
+ * @since 3.5
90
+ */
91
+ public QueryMethod (Method method , RepositoryMetadata metadata , ProjectionFactory factory ,
92
+ @ Nullable Function <ParametersSource , ? extends Parameters <?, ?>> parametersFunction ) {
73
93
74
94
Assert .notNull (method , "Method must not be null" );
75
95
Assert .notNull (metadata , "Repository metadata must not be null" );
@@ -86,7 +106,8 @@ public QueryMethod(Method method, RepositoryMetadata metadata, ProjectionFactory
86
106
this .method = method ;
87
107
this .unwrappedReturnType = potentiallyUnwrapReturnTypeFor (metadata , method );
88
108
this .metadata = metadata ;
89
- this .parameters = createParameters (method , metadata .getDomainTypeInformation ());
109
+ this .parameters = parametersFunction == null ? createParameters (method , metadata .getDomainTypeInformation ())
110
+ : parametersFunction .apply (ParametersSource .of (metadata , method ));
90
111
91
112
this .domainClass = Lazy .of (() -> {
92
113
@@ -186,7 +207,10 @@ private boolean calculateIsCollectionQuery() {
186
207
* @param parametersSource must not be {@literal null}.
187
208
* @return must not return {@literal null}.
188
209
* @since 3.2.1
210
+ * @deprecated since 3.5, use {@link QueryMethod#QueryMethod(Method, RepositoryMetadata, ProjectionFactory, Function)}
211
+ * instead.
189
212
*/
213
+ @ Deprecated (since = "3.5" )
190
214
protected Parameters <?, ?> createParameters (ParametersSource parametersSource ) {
191
215
return new DefaultParameters (parametersSource );
192
216
}
0 commit comments