|
10 | 10 | *******************************************************************************/ |
11 | 11 | package org.springframework.ide.vscode.boot.java.data; |
12 | 12 |
|
| 13 | +import java.util.Objects; |
13 | 14 | import java.util.Optional; |
14 | 15 |
|
15 | 16 | import org.eclipse.jdt.core.dom.IMethodBinding; |
|
20 | 21 | public record DataRepositoryAotMetadata (String name, String type, DataRepositoryModule module, IDataRepositoryAotMethodMetadata[] methods) { |
21 | 22 |
|
22 | 23 | public Optional<IDataRepositoryAotMethodMetadata> findMethod(IMethodBinding method) { |
23 | | - String name = method.getName(); |
| 24 | + String methodName = method.getName(); |
24 | 25 |
|
25 | | - for (IDataRepositoryAotMethodMetadata methodMetadata : methods()) { |
26 | | - |
27 | | - if (methodMetadata.getName() != null && methodMetadata.getName().equals(name)) { |
28 | | - |
29 | | - String signature = methodMetadata.getSignature(); |
30 | | - JLRMethod parsedMethodSignature = JLRMethodParser.parse(signature); |
| 26 | + if (methodName != null) { |
| 27 | + for (IDataRepositoryAotMethodMetadata methodMetadata : methods()) { |
31 | 28 |
|
32 | | - if (parsedMethodSignature.getFQClassName().equals(name()) |
33 | | - && parsedMethodSignature.getMethodName().equals(method.getName()) |
34 | | - && parsedMethodSignature.getReturnType().equals(method.getReturnType().getQualifiedName()) |
35 | | - && parameterMatches(parsedMethodSignature, method)) { |
36 | | - return Optional.of(methodMetadata); |
| 29 | + if (methodMetadata.getName() != null && methodMetadata.getName().equals(methodName)) { |
| 30 | + |
| 31 | + String signature = methodMetadata.getSignature(); |
| 32 | + JLRMethod parsedMethodSignature = JLRMethodParser.parse(signature); |
| 33 | + |
| 34 | + if (Objects.equals(name(), parsedMethodSignature.getFQClassName()) |
| 35 | + && methodName.equals(parsedMethodSignature.getMethodName()) |
| 36 | + && Objects.equals(parsedMethodSignature.getReturnType(), method.getReturnType().getQualifiedName()) |
| 37 | + && parameterMatches(parsedMethodSignature, method)) { |
| 38 | + return Optional.of(methodMetadata); |
| 39 | + } |
37 | 40 | } |
38 | 41 | } |
39 | | - } |
| 42 | + } |
40 | 43 |
|
41 | 44 | return Optional.empty(); |
42 | 45 | } |
|
0 commit comments