MCPcopy Index your code
hub / github.com/google/dagger / lazy

Method lazy

java/dagger/internal/DoubleCheck.java:83–95  ·  view source on GitHub ↗
(P provider)

Source from the content-addressed store, hash-verified

81 // This method is declared this way instead of "<T> Lazy<T> lazy(Provider<T> delegate)"
82 // to work around an Eclipse type inference bug: https://github.com/google/dagger/issues/949.
83 public static <P extends Provider<T>, T> Lazy<T> lazy(P provider) {
84 if (provider instanceof Lazy) {
85 @SuppressWarnings("unchecked")
86 final Lazy<T> lazy = (Lazy<T>) provider;
87 // Avoids memoizing a value that is already memoized.
88 // NOTE: There is a pathological case where Provider<P> may implement Lazy<L>, but P and L
89 // are different types using covariant return on get(). Right now this is used with
90 // DoubleCheck<T> exclusively, which is implemented such that P and L are always
91 // the same, so it will be fine for that case.
92 return lazy;
93 }
94 return new DoubleCheck<T>(checkNotNull(provider));
95 }
96}

Callers 5

doubleWrapping_lazyMethod · 0.95
getMethod · 0.95
getMethod · 0.95

Calls 1

checkNotNullMethod · 0.80

Tested by 4

doubleWrapping_lazyMethod · 0.76
getMethod · 0.76