33
33
* converted for invocation of implementation methods.
34
34
*
35
35
* @author Mark Paluch
36
+ * @since 2.0
36
37
*/
37
38
public class ReactiveRepositoryInformation extends DefaultRepositoryInformation {
38
39
@@ -75,7 +76,7 @@ Method getTargetClassMethod(Method method, Class<?> baseClass) {
75
76
boolean wantsWrappers = wantsMethodUsingReactiveWrapperParameters (method );
76
77
77
78
if (wantsWrappers ) {
78
- Method candidate = getMethodCandidate (method , baseClass , new ExactWrapperMatch (method ));
79
+ Method candidate = getMethodCandidate (method , baseClass , new AssignableWrapperMatch (method ));
79
80
80
81
if (candidate != null ) {
81
82
return candidate ;
@@ -171,6 +172,11 @@ static boolean isNonunwrappingWrapper(Class<?> parameterType) {
171
172
&& !QueryExecutionConverters .supportsUnwrapping (parameterType );
172
173
}
173
174
175
+ /**
176
+ * {@link BiPredicate} to check whether a method parameter is a {@link #isNonunwrappingWrapper(Class)} and can be
177
+ * converted into a different wrapper. Usually {@link rx.Observable} to {@link org.reactivestreams.Publisher}
178
+ * conversion.
179
+ */
174
180
static class WrapperConversionMatch implements BiPredicate <Class <?>, Integer > {
175
181
176
182
final Method declaredMethod ;
@@ -187,7 +193,6 @@ public WrapperConversionMatch(Method declaredMethod, ConversionService conversio
187
193
@ Override
188
194
public boolean test (Class <?> candidateParameterType , Integer index ) {
189
195
190
- // TODO: should check for component type
191
196
if (isNonunwrappingWrapper (candidateParameterType ) && isNonunwrappingWrapper (declaredParameterTypes [index ])) {
192
197
193
198
if (conversionService .canConvert (declaredParameterTypes [index ], candidateParameterType )) {
@@ -197,15 +202,19 @@ public boolean test(Class<?> candidateParameterType, Integer index) {
197
202
198
203
return false ;
199
204
}
200
-
201
205
}
202
206
203
- static class ExactWrapperMatch implements BiPredicate <Class <?>, Integer > {
207
+ /**
208
+ * {@link BiPredicate} to check parameter assignability between a {@link #isNonunwrappingWrapper(Class)} parameter and
209
+ * a declared parameter. Usually {@link reactor.core.publisher.Flux} vs. {@link org.reactivestreams.Publisher}
210
+ * conversion.
211
+ */
212
+ static class AssignableWrapperMatch implements BiPredicate <Class <?>, Integer > {
204
213
205
214
final Method declaredMethod ;
206
215
final Class <?>[] declaredParameterTypes ;
207
216
208
- public ExactWrapperMatch (Method declaredMethod ) {
217
+ public AssignableWrapperMatch (Method declaredMethod ) {
209
218
210
219
this .declaredMethod = declaredMethod ;
211
220
this .declaredParameterTypes = declaredMethod .getParameterTypes ();
@@ -214,7 +223,6 @@ public ExactWrapperMatch(Method declaredMethod) {
214
223
@ Override
215
224
public boolean test (Class <?> candidateParameterType , Integer index ) {
216
225
217
- // TODO: should check for component type
218
226
if (isNonunwrappingWrapper (candidateParameterType ) && isNonunwrappingWrapper (declaredParameterTypes [index ])) {
219
227
220
228
if (declaredParameterTypes [index ].isAssignableFrom (candidateParameterType )) {
@@ -224,9 +232,14 @@ public boolean test(Class<?> candidateParameterType, Integer index) {
224
232
225
233
return false ;
226
234
}
227
-
228
235
}
229
236
237
+ /**
238
+ * {@link BiPredicate} to check parameter assignability between a parameters in which the declared parameter may be
239
+ * wrapped but supports unwrapping. Usually types like {@link java.util.Optional} or {@link java.util.stream.Stream}.
240
+ *
241
+ * @see QueryExecutionConverters
242
+ */
230
243
static class MatchParameterOrComponentType implements BiPredicate <Class <?>, Integer > {
231
244
232
245
final Method declaredMethod ;
@@ -253,7 +266,5 @@ public boolean test(Class<?> candidateParameterType, Integer index) {
253
266
254
267
return true ;
255
268
}
256
-
257
269
}
258
-
259
270
}
0 commit comments