/** * We tolerate duplicate bindings if one exposes the other or if the two bindings are considered * duplicates (see {@link Bindings#areDuplicates(BindingImpl, BindingImpl)}. * * @param original the binding in the parent injector (candidate for an exposing binding) * @param binding the binding to check (candidate for the exposed binding) */ private boolean isOkayDuplicate(BindingImpl<?> original, BindingImpl<?> binding, State state) { if (original instanceof ExposedBindingImpl) { ExposedBindingImpl exposed = (ExposedBindingImpl) original; InjectorImpl exposedFrom = (InjectorImpl) exposed.getPrivateElements().getInjector(); return (exposedFrom == binding.getInjector()); } else { original = (BindingImpl<?>) state.getExplicitBindingsThisLevel().get(binding.getKey()); // If no original at this level, the original was on a parent, and we don't // allow deduplication between parents & children. if (original == null) { return false; } else { return original.equals(binding); } } }
@Override public void notify(Errors errors) { InjectorImpl privateInjector = (InjectorImpl) privateElements.getInjector(); BindingImpl<T> explicitBinding = privateInjector.state.getExplicitBinding(key); // validate that the child injector has its own factory. If the getInternalFactory() returns // this, then that child injector doesn't have a factory (and getExplicitBinding has returned // its parent's binding instead if (explicitBinding.getInternalFactory() == this) { errors.withSource(explicitBinding.getSource()).exposedButNotBound(key); return; } this.delegate = explicitBinding; }
Injector injector = exposedBinding.getPrivateElements().getInjector(); if (injector != null) { binding = injector.getBinding(exposedBinding.getKey());
Injector injector = exposedBinding.getPrivateElements().getInjector(); if (injector != null) { binding = injector.getBinding(exposedBinding.getKey());
/** * We tolerate duplicate bindings if one exposes the other or if the two bindings * are considered duplicates. * * @param original the binding in the parent injector (candidate for an exposing binding) * @param binding the binding to check (candidate for the exposed binding) */ private boolean isOkayDuplicate(BindingImpl<?> original, BindingImpl<?> binding, State state) { if (original instanceof ExposedBindingImpl) { ExposedBindingImpl exposed = (ExposedBindingImpl) original; InjectorImpl exposedFrom = (InjectorImpl) exposed.getPrivateElements().getInjector(); return (exposedFrom == binding.getInjector()); } else { original = (BindingImpl<?>) state.getExplicitBindingsThisLevel().get(binding.getKey()); // If no original at this level, the original was on a parent, and we don't // allow deduplication between parents & children. return original != null && original.equals(binding); } }
/** * We tolerate duplicate bindings if one exposes the other or if the two bindings are considered * duplicates (see {@link Bindings#areDuplicates(BindingImpl, BindingImpl)}. * * @param original the binding in the parent injector (candidate for an exposing binding) * @param binding the binding to check (candidate for the exposed binding) */ private boolean isOkayDuplicate(BindingImpl<?> original, BindingImpl<?> binding, State state) { if (original instanceof ExposedBindingImpl) { ExposedBindingImpl exposed = (ExposedBindingImpl) original; InjectorImpl exposedFrom = (InjectorImpl) exposed.getPrivateElements().getInjector(); return (exposedFrom == binding.getInjector()); } else { original = (BindingImpl<?>) state.getExplicitBindingsThisLevel().get(binding.getKey()); // If no original at this level, the original was on a parent, and we don't // allow deduplication between parents & children. if (original == null) { return false; } else { return original.equals(binding); } } }
/** * We tolerate duplicate bindings if one exposes the other or if the two bindings * are considered duplicates (see {@link Bindings#areDuplicates(BindingImpl, BindingImpl)}. * * @param original the binding in the parent injector (candidate for an exposing binding) * @param binding the binding to check (candidate for the exposed binding) */ private boolean isOkayDuplicate(BindingImpl<?> original, BindingImpl<?> binding, State state) { if (original instanceof ExposedBindingImpl) { ExposedBindingImpl exposed = (ExposedBindingImpl) original; InjectorImpl exposedFrom = (InjectorImpl) exposed.getPrivateElements().getInjector(); return (exposedFrom == binding.getInjector()); } else { original = (BindingImpl<?>)state.getExplicitBindingsThisLevel().get(binding.getKey()); // If no original at this level, the original was on a parent, and we don't // allow deduplication between parents & children. if(original == null) { return false; } else { return original.equals(binding); } } }
/** * We tolerate duplicate bindings if one exposes the other or if the two bindings are considered * duplicates (see {@link Bindings#areDuplicates(BindingImpl, BindingImpl)}. * * @param original the binding in the parent injector (candidate for an exposing binding) * @param binding the binding to check (candidate for the exposed binding) */ private boolean isOkayDuplicate(BindingImpl<?> original, BindingImpl<?> binding, State state) { if (original instanceof ExposedBindingImpl) { ExposedBindingImpl exposed = (ExposedBindingImpl) original; InjectorImpl exposedFrom = (InjectorImpl) exposed.getPrivateElements().getInjector(); return (exposedFrom == binding.getInjector()); } else { original = (BindingImpl<?>) state.getExplicitBindingsThisLevel().get(binding.getKey()); // If no original at this level, the original was on a parent, and we don't // allow deduplication between parents & children. if (original == null) { return false; } else { return original.equals(binding); } } }
/** * We tolerate duplicate bindings if one exposes the other or if the two bindings * are considered duplicates (see {@link Bindings#areDuplicates(BindingImpl, BindingImpl)}. * * @param original the binding in the parent injector (candidate for an exposing binding) * @param binding the binding to check (candidate for the exposed binding) */ private boolean isOkayDuplicate(BindingImpl<?> original, BindingImpl<?> binding, State state) { if (original instanceof ExposedBindingImpl) { ExposedBindingImpl exposed = (ExposedBindingImpl) original; InjectorImpl exposedFrom = (InjectorImpl) exposed.getPrivateElements().getInjector(); return (exposedFrom == binding.getInjector()); } else { original = (BindingImpl<?>)state.getExplicitBindingsThisLevel().get(binding.getKey()); // If no original at this level, the original was on a parent, and we don't // allow deduplication between parents & children. if(original == null) { return false; } else { return original.equals(binding); } } }
/** * We tolerate duplicate bindings if one exposes the other or if the two bindings * are considered duplicates (see {@link Bindings#areDuplicates(BindingImpl, BindingImpl)}. * * @param original the binding in the parent injector (candidate for an exposing binding) * @param binding the binding to check (candidate for the exposed binding) */ private boolean isOkayDuplicate(BindingImpl<?> original, BindingImpl<?> binding, State state) { if (original instanceof ExposedBindingImpl) { ExposedBindingImpl exposed = (ExposedBindingImpl) original; InjectorImpl exposedFrom = (InjectorImpl) exposed.getPrivateElements().getInjector(); return (exposedFrom == binding.getInjector()); } else { original = (BindingImpl<?>)state.getExplicitBindingsThisLevel().get(binding.getKey()); // If no original at this level, the original was on a parent, and we don't // allow deduplication between parents & children. if(original == null) { return false; } else { return original.equals(binding); } } }
@Override public Class<?> visit( final ExposedBinding<?> binding ) { return binding.getPrivateElements().getInjector().getBinding( binding.getKey() ).acceptTargetVisitor( this ); } }
public void notify(Errors errors) { InjectorImpl privateInjector = (InjectorImpl) privateElements.getInjector(); BindingImpl<T> explicitBinding = privateInjector.state.getExplicitBinding(key); // validate that the child injector has its own factory. If the getInternalFactory() returns // this, then that child injector doesn't have a factory (and getExplicitBinding has returned // its parent's binding instead if (explicitBinding.getInternalFactory() == this) { errors.withSource(explicitBinding.getSource()).exposedButNotBound(key); return; } this.delegate = explicitBinding; }
public void notify(Errors errors) { InjectorImpl privateInjector = (InjectorImpl) privateElements.getInjector(); BindingImpl<T> explicitBinding = privateInjector.state.getExplicitBinding(key); // validate that the child injector has its own factory. If the getInternalFactory() returns // this, then that child injector doesn't have a factory (and getExplicitBinding has returned // its parent's binding instead if (explicitBinding.getInternalFactory() == this) { errors.withSource(explicitBinding.getSource()).exposedButNotBound(key); return; } this.delegate = explicitBinding; }
@Override public void notify(Errors errors) { InjectorImpl privateInjector = (InjectorImpl) privateElements.getInjector(); BindingImpl<T> explicitBinding = privateInjector.state.getExplicitBinding(key); // validate that the child injector has its own factory. If the getInternalFactory() returns // this, then that child injector doesn't have a factory (and getExplicitBinding has returned // its parent's binding instead if (explicitBinding.getInternalFactory() == this) { errors.withSource(explicitBinding.getSource()).exposedButNotBound(key); return; } this.delegate = explicitBinding; }
public void notify(Errors errors) { InjectorImpl privateInjector = (InjectorImpl) privateElements.getInjector(); BindingImpl<T> explicitBinding = privateInjector.state.getExplicitBinding(key); // validate that the child injector has its own factory. If the getInternalFactory() returns // this, then that child injector doesn't have a factory (and getExplicitBinding has returned // its parent's binding instead if (explicitBinding.getInternalFactory() == this) { errors.withSource(explicitBinding.getSource()).exposedButNotBound(key); return; } this.delegate = explicitBinding; }
public void notify(Errors errors) { InjectorImpl privateInjector = (InjectorImpl) privateElements.getInjector(); BindingImpl<T> explicitBinding = privateInjector.state.getExplicitBinding(key); // validate that the child injector has its own factory. If the getInternalFactory() returns // this, then that child injector doesn't have a factory (and getExplicitBinding has returned // its parent's binding instead if (explicitBinding.getInternalFactory() == this) { errors.withSource(explicitBinding.getSource()).exposedButNotBound(key); return; } this.delegate = explicitBinding; }
@Override public void notify(Errors errors) { InjectorImpl privateInjector = (InjectorImpl) privateElements.getInjector(); BindingImpl<T> explicitBinding = privateInjector.state.getExplicitBinding(key); // validate that the child injector has its own factory. If the getInternalFactory() returns // this, then that child injector doesn't have a factory (and getExplicitBinding has returned // its parent's binding instead if (explicitBinding.getInternalFactory() == this) { errors.withSource(explicitBinding.getSource()).exposedButNotBound(key); return; } this.delegate = explicitBinding; }
Injector injector = exposedBinding.getPrivateElements().getInjector(); if (injector != null) { binding = injector.getBinding(exposedBinding.getKey());
/** * Returns true if {@code binding} is singleton-scoped. If the binding is a {@link * com.google.inject.spi.LinkedKeyBinding linked key binding} and belongs to an injector (ie. it * was retrieved via {@link Injector#getBinding Injector.getBinding()}), then this method will * also true if the target binding is singleton-scoped. */ public static boolean isSingleton(Binding<?> binding) { do { boolean singleton = binding.acceptScopingVisitor(IS_SINGLETON_VISITOR); if (singleton) { return true; } if (binding instanceof LinkedBindingImpl) { LinkedBindingImpl<?> linkedBinding = (LinkedBindingImpl) binding; Injector injector = linkedBinding.getInjector(); if (injector != null) { binding = injector.getBinding(linkedBinding.getLinkedKey()); continue; } } else if (binding instanceof ExposedBinding) { ExposedBinding<?> exposedBinding = (ExposedBinding) binding; Injector injector = exposedBinding.getPrivateElements().getInjector(); if (injector != null) { binding = injector.getBinding(exposedBinding.getKey()); continue; } } return false; } while (true); }
Injector injector = exposedBinding.getPrivateElements().getInjector(); if (injector != null) { binding = injector.getBinding(exposedBinding.getKey());