@Test public void getProvider_withDirectClass_shouldThrow() { try { container.getProvider(Float.class); fail("Expected exception not thrown."); } catch (IllegalArgumentException ex) { assertThat(ex.getMessage()).contains("java.lang.Float"); } }
@Override public <T> Provider<T> getProvider(Class<T> anInterface) { if (!allowedProviderInterfaces.contains(anInterface)) { throw new IllegalArgumentException( String.format( "Attempting to request an undeclared dependency Provider<%s>.", anInterface)); } return delegateContainer.getProvider(anInterface); }
RestrictedComponentContainer extends AbstractComponentContainer { @Override public <T> Provider<T> getProvider(Class<T> anInterface) { if (!allowedProviderInterfaces.contains(anInterface)) { throw new IllegalArgumentException( String.format( "Attempting to request an undeclared dependency Provider<%s>.", anInterface)); } return delegateContainer.getProvider(anInterface); } }
RestrictedComponentContainer extends AbstractComponentContainer { @Override public <T> Provider<T> getProvider(Class<T> anInterface) { if (!allowedProviderInterfaces.contains(anInterface)) { throw new IllegalArgumentException( String.format( "Attempting to request an undeclared dependency Provider<%s>.", anInterface)); } return delegateContainer.getProvider(anInterface); } RestrictedComponentContainer(Component<?> component, ComponentContainer container); }
RestrictedComponentContainer extends AbstractComponentContainer { @Override public <T> Provider<T> getProvider(Class<T> anInterface) { if (!allowedProviderInterfaces.contains(anInterface)) { throw new IllegalArgumentException( String.format( "Attempting to request an undeclared dependency Provider<%s>.", anInterface)); } return delegateContainer.getProvider(anInterface); } RestrictedComponentContainer(Component<?> component, ComponentContainer container); @Override T get(Class<T> anInterface); @Override Provider<T> getProvider(Class<T> anInterface); @Override Provider<Set<T>> setOfProvider(Class<T> anInterface); @Override Set<T> setOf(Class<T> anInterface); }
RestrictedComponentContainer extends AbstractComponentContainer { @Override public <T> Provider<T> getProvider(Class<T> anInterface) { if (!allowedProviderInterfaces.contains(anInterface)) { throw new IllegalArgumentException( String.format( "Attempting to request an undeclared dependency Provider<%s>.", anInterface)); } return delegateContainer.getProvider(anInterface); } RestrictedComponentContainer(Component<?> component, ComponentContainer container); @Override T get(Class<T> anInterface); @Override Provider<T> getProvider(Class<T> anInterface); @Override Provider<Set<T>> setOfProvider(Class<T> anInterface); @Override Set<T> setOf(Class<T> anInterface);  }