Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
* The first one tries to generate a binding for any missing key by searching for {@link Inject} constructors.
*
* The second one generates any Key<SomeType> instance for SomeType.
* Its purpose is to get reified types from generics in templated providers.
*
* The last three generate appropriate instances for {@link InstanceProvider}, {@link InstanceFactory} and {@link InstanceInjector} requests.
*/
public final class DefaultModule implements Module {
private static final Trie, Set>>> emptyTrie = Trie.leaf(new HashMap<>());
private static final Map, Set>> generators = new HashMap<>();
static {
// generating bindings for classes that have @Inject constructors/factory methods
generators.put(Object.class, singleton((bindings, scope, key) -> ReflectionUtils.generateImplicitBinding(key)));
// generating dummy bindings for reified type requests (can be used in templated providers to get a Key instance)
generators.put(Key.class, singleton((bindings, scope, key) -> Binding.toInstance(key.getTypeParameter(0))));
// generating bindings for provider requests
generators.put(InstanceProvider.class, singleton(
(bindings, scope, key) -> {
Key