/** * Adds a binding for T. Multiple calls to this are safe, and will be collapsed as duplicate * bindings. */ private void addDirectTypeBinding(Binder binder) { binder .bind(bindingSelection.getDirectKey()) .toProvider(new RealDirectTypeProvider<T>(bindingSelection)); }
@SuppressWarnings("unchecked") private void bindJava8Optional(Binder binder) { if (JAVA_OPTIONAL_CLASS != null) { Key<?> key = bindingSelection.getDirectKey(); TypeLiteral<?> typeLiteral = key.getTypeLiteral(); InternalProviderInstanceBindingImpl.Factory<Object> javaOptionalProviderFactory = new JavaOptionalProviderProvider(bindingSelection); binder .bind(key.ofType(javaOptionalOfProvider(typeLiteral))) .toProvider((Provider) javaOptionalProviderFactory); // Provider is assignable to javax.inject.Provider and the provider that the factory contains // cannot be modified so we can use some rawtypes hackery to share the same implementation. binder .bind(key.ofType(javaOptionalOfJavaxProvider(typeLiteral))) .toProvider((Provider) javaOptionalProviderFactory); Key<?> javaOptionalKey = key.ofType(javaOptionalOf(typeLiteral)); binder .bind(javaOptionalKey) .toProvider(new JavaOptionalProvider(bindingSelection, javaOptionalKey)); } }
@Override public void configure(Binder binder) { bindingSelection.checkNotInitialized(); Key<T> key = bindingSelection.getDirectKey();
@Override public void configure(Binder binder) { bindingSelection.checkNotInitialized(); Key<T> key = bindingSelection.getDirectKey();
@Override public void configure(Binder binder) { bindingSelection.checkNotInitialized(); Key<T> key = bindingSelection.getDirectKey();
@SuppressWarnings("unchecked") private void bindJava8Optional(Binder binder) { if (JAVA_OPTIONAL_CLASS != null) { Key<?> key = bindingSelection.getDirectKey(); TypeLiteral<?> typeLiteral = key.getTypeLiteral(); InternalProviderInstanceBindingImpl.Factory<Object> javaOptionalProviderFactory = new JavaOptionalProviderProvider(bindingSelection); binder .bind(key.ofType(javaOptionalOfProvider(typeLiteral))) .toProvider((Provider) javaOptionalProviderFactory); // Provider is assignable to javax.inject.Provider and the provider that the factory contains // cannot be modified so we can use some rawtypes hackery to share the same implementation. binder .bind(key.ofType(javaOptionalOfJavaxProvider(typeLiteral))) .toProvider((Provider) javaOptionalProviderFactory); Key<?> javaOptionalKey = key.ofType(javaOptionalOf(typeLiteral)); binder .bind(javaOptionalKey) .toProvider(new JavaOptionalProvider(bindingSelection, javaOptionalKey)); } }
@SuppressWarnings("unchecked") private void bindJava8Optional(Binder binder) { if (JAVA_OPTIONAL_CLASS != null) { Key<?> key = bindingSelection.getDirectKey(); TypeLiteral<?> typeLiteral = key.getTypeLiteral(); InternalProviderInstanceBindingImpl.Factory<Object> javaOptionalProviderFactory = new JavaOptionalProviderProvider(bindingSelection); binder .bind(key.ofType(javaOptionalOfProvider(typeLiteral))) .toProvider((Provider) javaOptionalProviderFactory); // Provider is assignable to javax.inject.Provider and the provider that the factory contains // cannot be modified so we can use some rawtypes hackery to share the same implementation. binder .bind(key.ofType(javaOptionalOfJavaxProvider(typeLiteral))) .toProvider((Provider) javaOptionalProviderFactory); Key<?> javaOptionalKey = key.ofType(javaOptionalOf(typeLiteral)); binder .bind(javaOptionalKey) .toProvider(new JavaOptionalProvider(bindingSelection, javaOptionalKey)); } }
/** * Adds a binding for T. Multiple calls to this are safe, and will be collapsed as duplicate * bindings. */ private void addDirectTypeBinding(Binder binder) { binder .bind(bindingSelection.getDirectKey()) .toProvider(new RealDirectTypeProvider<T>(bindingSelection)); }
/** * Adds a binding for T. Multiple calls to this are safe, and will be collapsed as duplicate * bindings. */ private void addDirectTypeBinding(Binder binder) { binder .bind(bindingSelection.getDirectKey()) .toProvider(new RealDirectTypeProvider<T>(bindingSelection)); }