From 837587d53fa73fdc4c66589d76ab0007b7158b27 Mon Sep 17 00:00:00 2001 From: jbock Date: Sun, 3 Dec 2023 13:06:57 +0100 Subject: [PATCH] ISSUES-17 allow sibling binding --- .../processor/binding/InjectBindingFactory.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/compiler/src/main/java/io/jbock/simple/processor/binding/InjectBindingFactory.java b/compiler/src/main/java/io/jbock/simple/processor/binding/InjectBindingFactory.java index e658f82..d4a23d2 100644 --- a/compiler/src/main/java/io/jbock/simple/processor/binding/InjectBindingFactory.java +++ b/compiler/src/main/java/io/jbock/simple/processor/binding/InjectBindingFactory.java @@ -48,14 +48,12 @@ private Map injectBindingsMiss(TypeElement typeElement) { } public Optional binding(Key key) { - return tool.types().asElement(key.type()).flatMap(element -> { - TypeElement typeElement = TYPE_ELEMENT_VISITOR.visit(element); - if (typeElement == null) { - return Optional.empty(); - } - Map m = injectBindings(typeElement); - return Optional.ofNullable(m.get(key)); - }); + return tool.types().asElement(key.type()) + .map(TYPE_ELEMENT_VISITOR::visit) + .flatMap(typeElement -> { + Map m = injectBindings(typeElement); + return Optional.ofNullable(m.get(key)); + }); } @Override