Class RealOptionalBinder<T>

java.lang.Object
com.google.inject.internal.RealOptionalBinder<T>
All Implemented Interfaces:
Module

public final class RealOptionalBinder<T> extends Object implements Module
The actual OptionalBinder plays several roles. It implements Module to hide that fact from the public API, and installs the various bindings that are exposed to the user.
  • Field Details

  • Constructor Details

    • RealOptionalBinder

      private RealOptionalBinder(Binder binder, Key<T> typeKey)
  • Method Details

    • newRealOptionalBinder

      public static <T> RealOptionalBinder<T> newRealOptionalBinder(Binder binder, Key<T> type)
    • optionalOf

      static <T> TypeLiteral<com.google.common.base.Optional<T>> optionalOf(TypeLiteral<T> type)
    • javaOptionalOf

      static <T> TypeLiteral<Optional<T>> javaOptionalOf(TypeLiteral<T> type)
    • optionalOfJavaxProvider

      static <T> TypeLiteral<com.google.common.base.Optional<javax.inject.Provider<T>>> optionalOfJavaxProvider(TypeLiteral<T> type)
    • javaOptionalOfJavaxProvider

      static <T> TypeLiteral<Optional<javax.inject.Provider<T>>> javaOptionalOfJavaxProvider(TypeLiteral<T> type)
    • optionalOfProvider

      static <T> TypeLiteral<com.google.common.base.Optional<Provider<T>>> optionalOfProvider(TypeLiteral<T> type)
    • javaOptionalOfProvider

      static <T> TypeLiteral<Optional<Provider<T>>> javaOptionalOfProvider(TypeLiteral<T> type)
    • providerOf

      static <T> Key<Provider<T>> providerOf(Key<T> key)
    • addDirectTypeBinding

      private void addDirectTypeBinding(Binder binder)
      Adds a binding for T. Multiple calls to this are safe, and will be collapsed as duplicate bindings.
    • getKeyForDefaultBinding

      Key<T> getKeyForDefaultBinding()
      Returns the key to use for the default binding.

      As a side effect this installs support for the 'direct type', so a binding for T will be made available.

    • setDefault

      public LinkedBindingBuilder<T> setDefault()
    • getKeyForActualBinding

      Key<T> getKeyForActualBinding()
      Returns the key to use for the actual binding, overrides the default if set.

      As a side effect this installs support for the 'direct type', so a binding for T will be made available.

    • setBinding

      public LinkedBindingBuilder<T> setBinding()
    • configure

      public void configure(Binder binder)
      Description copied from interface: Module
      Contributes bindings and other configurations for this module to binder.

      Do not invoke this method directly to install submodules. Instead use Binder.install(Module), which ensures that provider methods are discovered.

      Specified by:
      configure in interface Module
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object