All Downloads are FREE. Search and download functionalities are using the official Maven repository.

javax0.Simple.Lazy Maven / Gradle / Ivy

package javax0.Simple;

import java.util.function.Supplier;

public class Lazy implements Supplier {

    final private Supplier supplier;
    private boolean supplied = false;
    private T value;

    private Lazy(Supplier supplier) {
        this.supplier = supplier;
    }

    public static  Lazy let(Supplier supplier) {
        return new Lazy(supplier);
    }

    @Override
    public T get() {
        if (supplied) {
            return value;
        }
        supplied = true;
        return value = supplier.get();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy