Package 

Class DependencyProvider


  • 
    public final class DependencyProvider<T extends Object>
    
                        

    A generic class used for lazy dependency injection, ensuring that dependencies are initialized only when they are accessed. This approach helps in deferring the initialization cost until the dependency is actually needed, which can be particularly useful for heavy resources or services.

    • Constructor Summary

      Constructors 
      Constructor Description
      DependencyProvider(Function0<T> instanceGenerator)
    • Method Summary

      Modifier and Type Method Description
      final T get() Retrieves an instance of type T by invoking the instance generation lambda.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DependencyProvider

        DependencyProvider(Function0<T> instanceGenerator)
        Parameters:
        instanceGenerator - The lambda block that generates an instance of type T.
    • Method Detail

      • get

         final T get()

        Retrieves an instance of type T by invoking the instance generation lambda. This method provides lazy initialization, as the dependency is created only when this method is called.