public < T > InjectorConfiguration withFactory ( Class < T > classDefinition , Provider < T > factory ) { if ( classDefinition . equals ( Injector . class ) ) { throw new DependencyInjectionFailedException ( "Cowardly refusing to define a global factory for Injector since that would lead to a Service Locator pattern. If you need the injector, please define it on a per-class or per-method basis." ) ; } //noinspection unchecked return new InjectorConfiguration ( scopes , definedClasses , factories . withModified ( ( value ) - > value . with ( classDefinition , factory ) ) , factoryClasses , sharedClasses , sharedInstances , aliases , collectedAliases , namedParameterValues ) ; }
Specify that the given class should be created using the factory instance specified .