yangys
2024-04-04 2cf2921440e7473ae50796c2cb688f609b3a7995
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.qianwen.core.tool.utils;
 
import java.io.Serializable;
import java.util.function.Supplier;
import org.springframework.lang.Nullable;
 
/* loaded from: blade-core-tool-9.3.0.0-SNAPSHOT.jar:org/springblade/core/tool/utils/Lazy.class */
public class Lazy<T> implements Supplier<T>, Serializable {
    @Nullable
    private volatile transient Supplier<? extends T> supplier;
    @Nullable
    private T value;
 
    public static <T> Lazy<T> of(final Supplier<T> supplier) {
        return new Lazy<>(supplier);
    }
 
    /* JADX WARN: Multi-variable type inference failed */
    private Lazy(final Supplier<T> supplier) {
        this.supplier = supplier;
    }
 
    @Override // java.util.function.Supplier
    @Nullable
    public T get() {
        return this.supplier == null ? this.value : computeValue();
    }
 
    @Nullable
    private synchronized T computeValue() {
        Supplier<? extends T> s = this.supplier;
        if (s != null) {
            this.value = s.get();
            this.supplier = null;
        }
        return this.value;
    }
}