@Override @SuppressWarnings("unchecked") public <B, V> V acceptExtensionVisitor( BindingTargetVisitor<B, V> visitor, ProviderInstanceBinding<? extends B> binding) { if (visitor instanceof ProvidesMethodTargetVisitor) { return ((ProvidesMethodTargetVisitor<T, V>) visitor).visit(this); } return visitor.visit(binding); }
@Override @SuppressWarnings("unchecked") // the extension type is always consistent with the provider type public <V> V acceptTargetVisitor(BindingTargetVisitor<? super T, V> visitor) { if (providerInstance instanceof ProviderWithExtensionVisitor) { return ((ProviderWithExtensionVisitor<? extends T>) providerInstance) .acceptExtensionVisitor(visitor, this); } else { return visitor.visit(this); } }
@Override public <T> Provider<T> getProvider(final Key<T> key) { return getProvider(Dependency.get(key)); }
@Override public Message apply(String input) { return new Message(StringUtils.format("%s%s", propertyBase, input)); } }
@Override public <T> Provider<T> getProvider(final Dependency<T> dependency) { final ProviderLookup<T> element = new ProviderLookup<>(getElementSource(), dependency); elements.add(element); return element.getProvider(); }
@Override public void configure(Binder binder) { for (Element element : elements) { element.applyTo(binder); } } }
@Override public void requestStaticInjection(Class<?>... types) { for (Class<?> type : types) { elements.add(new StaticInjectionRequest(getElementSource(), type)); } }
@Override public <T> T acceptVisitor(ElementVisitor<T> visitor) { return visitor.visit(this); } }
public StaticInjection(InjectorImpl injector, StaticInjectionRequest request) { this.injector = injector; this.source = request.getSource(); this.request = request; }
@Override public String toString() { Dependency<?> dep = getDependency(); Object source = getBindingSource(); if (dep != null) { return "Dependency: " + dep + ", source: " + source; } else { return "Source: " + source; } } }
/** * Returns a new injection point for the specified method of {@code type}. This is useful for * extensions that need to build dependency graphs from arbitrary methods. * * @param method any single method present on {@code type}. * @param type the concrete type that defines {@code method}. * @since 4.0 */ public static <T> InjectionPoint forMethod(Method method, TypeLiteral<T> type) { return new InjectionPoint(type, method, false); }
@Override public V visit(InterceptorBinding interceptorBinding) { return visitOther(interceptorBinding); } /*end[AOP]*/
@Override public V visitNoScoping() { return visitOther(); } }
/** * Creates and returns a child {@link ModuleSource} corresponding to the {@link Module module}. * * @param module the corresponding module * @param partialCallStack the chunk of call stack that starts from the parent module {@link * Module#configure(Binder) configure(Binder)} call and ends just before the module {@link * Module#configure(Binder) configure(Binder)} method invocation */ ModuleSource createChild(Object module, StackTraceElement[] partialCallStack) { return new ModuleSource(this, module, partialCallStack); }
/** * Returns the size of call stack that ends just before the module {@link Module#configure(Binder) * configure(Binder)} method invocation (see {@link #getStackTrace()}). */ int getStackTraceSize() { if (parent == null) { return partialCallStack.length; } return parent.getStackTraceSize() + partialCallStack.length; }
@Override public <T> T acceptVisitor(ElementVisitor<T> visitor) { return visitor.visit(this); } }
@Override InjectionPoint toInjectionPoint() { return new InjectionPoint(declaringType, field, optional); } }
@Override public V visit(ModuleAnnotatedMethodScannerBinding binding) { return visitOther(binding); } }
@Override public <T> T acceptVisitor(ElementVisitor<T> visitor) { return visitor.visit(this); } }
@Override public <T> T acceptVisitor(ElementVisitor<T> visitor) { return visitor.visit(this); } }