ScopeImpl extends ScopeNode { <T> InternalProvider<T> toProvider(Binding<T> binding) { if (binding == null) { throw new IllegalStateException( "null binding are not allowed. Should not happen unless getBindingSet is overridden."); } ConfigurationHolder.configuration.checkIllegalBinding(binding, this); switch (binding.getMode()) { case SIMPLE: return new InternalScopedProvider<T>( this, binding.getKey(), binding.isCreatingSingleton(), binding.isCreatingReleasable()); case CLASS: return new InternalScopedProvider<T>( this, binding.getImplementationClass(), binding.isCreatingSingleton(), binding.isCreatingReleasable()); case INSTANCE: return new InternalScopedProvider<>(this, binding.getInstance()); case PROVIDER_INSTANCE: return new InternalScopedProvider<>( this, binding.getProviderInstance(), binding.isProvidingSingleton(), binding.isProvidingReleasable()); case PROVIDER_CLASS: return new InternalScopedProvider<T>( this, binding.getProviderClass(), binding.isCreatingSingleton(), binding.isCreatingReleasable(), binding.isProvidingSingleton(), binding.isProvidingReleasable()); default: throw new IllegalStateException( format("mode is not handled: %s. This should not happen.", binding.getMode())); } } ScopeImpl(Object name); @Override T getInstance(Class<T> clazz); @Override T getInstance(Class<T> clazz, String name); @Override Provider<T> getProvider(Class<T> clazz); @Override Provider<T> getProvider(Class<T> clazz, String name); @Override Lazy<T> getLazy(Class<T> clazz); @Override Lazy<T> getLazy(Class<T> clazz, String name); @Override synchronized Scope installTestModules(Module... modules); @Override Scope installModules(Module... modules); @Override void inject(Object obj); @Override String toString(); @Override Scope openSubScope(Object subScopeName); @Override Scope openSubScope(Object subScopeName, ScopeConfig scopeConfig); @Override void release();  }
@Test(expected = IllegalStateException.class) public void testToBinding_shouldFail_whenAddingANullBinding() { new ScopeImpl("").toProvider(null); }