Module dagger

Class DoubleCheck<T>

  • All Implemented Interfaces:
    Lazy<T>, jakarta.inject.Provider<T>

    public final class DoubleCheck<T>
    extends java.lang.Object
    implements jakarta.inject.Provider<T>, Lazy<T>
    A Lazy and Provider implementation that memoizes the value returned from a delegate using the double-check idiom described in Item 71 of Effective Java 2.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      T get()
      Return the underlying value, computing the value if necessary.
      static <P extends jakarta.inject.Provider<T>,​T>
      Lazy<T>
      lazy​(P provider)
      Returns a Lazy that caches the value from the given provider.
      static <P extends jakarta.inject.Provider<T>,​T>
      jakarta.inject.Provider<T>
      provider​(P delegate)
      Returns a Provider that caches the value from the given delegate provider.
      • Methods inherited from class java.lang.Object

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

      • get

        public T get()
        Description copied from interface: Lazy
        Return the underlying value, computing the value if necessary. All calls to the same Lazy instance will return the same result.
        Specified by:
        get in interface Lazy<T>
        Specified by:
        get in interface jakarta.inject.Provider<T>
      • provider

        public static <P extends jakarta.inject.Provider<T>,​T> jakarta.inject.Provider<T> provider​(P delegate)
        Returns a Provider that caches the value from the given delegate provider.
      • lazy

        public static <P extends jakarta.inject.Provider<T>,​T> Lazy<T> lazy​(P provider)
        Returns a Lazy that caches the value from the given provider.