private static Module extractScanners(Iterable<Element> elements) { final List<ModuleAnnotatedMethodScannerBinding> scanners = Lists.newArrayList(); ElementVisitor<Void> visitor = new DefaultElementVisitor<Void>() { @Override public Void visit(ModuleAnnotatedMethodScannerBinding binding) { scanners.add(binding); return null; } }; for (Element element : elements) { element.acceptVisitor(visitor); } return new AbstractModule() { @Override protected void configure() { for (ModuleAnnotatedMethodScannerBinding scanner : scanners) { scanner.applyTo(binder()); } } }; }
public static List<Element> visit(ElementVisitor<?> visitor, Iterable<? extends Module> modules) { final List<Element> elements = Elements.getElements(Stage.TOOL, modules); elements.forEach(e -> e.acceptVisitor(visitor)); return elements; }
public static List<Element> visit(ElementVisitor<?> visitor, Module... modules) { return visit(visitor, Arrays.asList(modules)); }
@Override public <T> T acceptVisitor(ElementVisitor<T> visitor) { return visitor.visit(this); }
@Override public <V> V acceptVisitor(ElementVisitor<V> visitor) { return visitor.visit(this); }
@Override protected void checkModule(Module module, ElementVisitor<?>... visitors) { Module overridden = Modules.override(module).with(Modules.EMPTY_MODULE); super.checkModule(overridden, visitors); }
public <T> T acceptVisitor(ElementVisitor<T> visitor) { return visitor.visit(this); }
public <V> V acceptVisitor(ElementVisitor<V> visitor) { return visitor.visit(this); }
protected void checkModule(Module module, ElementVisitor<?>... visitors) { Module overridden = Modules.override(module).with(Modules.EMPTY_MODULE); super.checkModule(overridden, visitors); }