InjectorBuilderImpl implements InjectorBuilder { @Override public InjectorBuilder withInjectorProxy(InjectorProxy injectorProxy) { requireNonNull(injectorProxy); proxies.addFirst(injectorProxy); return this; } InjectorBuilderImpl();   InjectorBuilderImpl(ClassLoader classLoader);   InjectorBuilderImpl(Set<Class<?>> injectables); private  InjectorBuilderImpl(ClassLoader classLoader, Set<Class<?>> injectables);   InjectorBuilderImpl(final InjectorBuilder toCopy); @Override InjectorBuilder withComponent(Class<?> injectableType); @Override InjectorBuilder withComponent(Class<T> injectableType, Supplier<T> instanceSupplier); @Override InjectorBuilder withBundle(Class<? extends InjectBundle> bundleClass); @Override InjectorBuilder withInjectorProxy(InjectorProxy injectorProxy); @Override InjectorBuilder withConfigFileLocation(Path configFile); @Override InjectorBuilder withParam(String name, String value); @Override InjectorBuilder before(ExecutionBuilder<T> executionBuilder); @Override Injector build(); @Override InjectorProxy proxyFor(Class<?> clazz); static final Logger INTERNAL_LOGGER; }
@Test void withInjectorProxy() throws InstantiationException { final class MyTestInjectorProxy implements InjectorProxy { @Override public boolean isApplicable(Class<?> clazz) { return true; } @Override public void set(Field field, Object instance, Object value) { throw new UnsupportedOperationException(); } @Override public Object invoke(Method method, Object obj, Object... args) { throw new UnsupportedOperationException(); } @Override public <T> T newInstance(Constructor<T> constructor, Object... args) throws IllegalAccessException, InvocationTargetException, InstantiationException { final T result = constructor.newInstance(args); if (result instanceof Bar) { ((Bar)result).val = 1; } return result; } } final Injector injector = instance.withInjectorProxy(new MyTestInjectorProxy()).withComponent(Bar.class).build(); assertEquals(1, injector.getOrThrow(Bar.class).val); }