fix: logical flaw in error handling

This commit is contained in:
zaaarf 2023-03-25 21:48:53 +01:00
parent d2fe55db7a
commit 3cea0d3e66
No known key found for this signature in database
GPG key ID: 82240E075E31FA4C

View file

@ -248,18 +248,17 @@ public class LilleroProcessor extends AbstractProcessor {
.stream() .stream()
.filter(i -> i.getSimpleName().contentEquals(targetAnn.of())) .filter(i -> i.getSimpleName().contentEquals(targetAnn.of()))
.collect(Collectors.toList()); .collect(Collectors.toList());
} else if(injectors.size() == 1) { } else if(injectors.size() == 1 && targets.size() == 1) {
//case 2: there is only one injector //case 2: there is only one target, must use it for that injector
finderCandidates = new ArrayList<>(); //no candidates finderCandidates = new ArrayList<>(); //no candidates
injectorCandidates = new ArrayList<>(); injectorCandidates = new ArrayList<>();
injectorCandidates.add(injectors.get(0)); injectorCandidates.add(injectors.get(0));
} else { } else {
//case 3: try to match by injectTargetName or same name for finers //case 3: try to match by injectTargetName or same name for finders
String inferredName = "inject" + tg.getSimpleName();
injectorCandidates = injectorCandidates =
injectorCandidates injectorCandidates
.stream() .stream()
.filter(t -> t.getSimpleName().toString().equalsIgnoreCase(inferredName)) .filter(t -> t.getSimpleName().toString().equalsIgnoreCase("inject" + tg.getSimpleName()))
.collect(Collectors.toList()); .collect(Collectors.toList());
finderCandidates = finderCandidates =
finderCandidates finderCandidates