com.softicar.platform.common.core.supplier.LazySupplier Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of platform-common Show documentation
Show all versions of platform-common Show documentation
The SoftiCAR Platform is a lightweight, Java-based library to create interactive business web applications.
package com.softicar.platform.common.core.supplier;
import java.util.Objects;
import java.util.function.Supplier;
public class LazySupplier implements Supplier {
private final Supplier supplier;
private T value;
public LazySupplier(Supplier supplier) {
this.supplier = Objects.requireNonNull(supplier);
this.value = null;
}
@Override
public T get() {
if (value == null) {
this.value = supplier.get();
}
return value;
}
}