Class RealOptionalBinder<T>

  • All Implemented Interfaces:
    Module

    public final class RealOptionalBinder<T>
    extends java.lang.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.
    • Constructor Detail

      • RealOptionalBinder

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

      • optionalOf

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

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

        static <T> TypeLiteral<java.util.Optional<javax.inject.Provider<T>>> javaOptionalOfJavaxProvider​(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.

      • 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.

      • 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​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object