Class DICollectionBuilder<K,​E>

  • Type Parameters:
    K - DI key type.
    E - Collection element type.
    All Implemented Interfaces:
    ScopeBuilder

    public abstract class DICollectionBuilder<K,​E>
    extends Object
    implements ScopeBuilder
    A superclass of DI List and Map builders.
    • Field Detail

      • bindingKey

        protected final Key<K> bindingKey
    • Constructor Detail

      • DICollectionBuilder

        public DICollectionBuilder​(Key<K> bindingKey,
                                   DefaultInjector injector)
    • Method Detail

      • createInstanceProvider

        protected javax.inject.Provider<E> createInstanceProvider​(E value)
      • createProviderProvider

        protected javax.inject.Provider<E> createProviderProvider​(Class<? extends javax.inject.Provider<? extends E>> providerType)
      • getByTypeProvider

        protected <SubT extends E> javax.inject.Provider<SubT> getByTypeProvider​(Class<SubT> interfaceType)
      • getByKeyProvider

        protected <SubT extends E> javax.inject.Provider<SubT> getByKeyProvider​(Key<SubT> key)
      • in

        public void in​(Scope scope)
        Description copied from interface: ScopeBuilder
        Sets the scope of a bound instance. This method is used to change the default scope which is a singleton by default to a custom scope.
        Specified by:
        in in interface ScopeBuilder
      • inSingletonScope

        public void inSingletonScope()
        Description copied from interface: ScopeBuilder
        Sets the scope of a bound instance to singleton. Singleton is normally the default.
        Specified by:
        inSingletonScope in interface ScopeBuilder
      • withoutScope

        public void withoutScope()
        Description copied from interface: ScopeBuilder
        Sets the scope of a bound instance to "no scope". This means that a new instance of an object will be created on every call to Injector.getInstance(Class) or to Provider of this instance.
        Specified by:
        withoutScope in interface ScopeBuilder
      • initOnStartup

        public void initOnStartup()
        Description copied from interface: ScopeBuilder
        Marks this injection point to be triggered early without explicit call to Injector.getInstance(Class). Such service will be created right after Injector is fully setup. NOTE: use with caution, as this will effectively create all graph of services that this service depends on.
        Specified by:
        initOnStartup in interface ScopeBuilder