io.polaris.core.tuple.Ref Maven / Gradle / Ivy
package io.polaris.core.tuple;
import java.util.function.Supplier;
/**
* @author Qt
* @since 1.8
*/
@FunctionalInterface
public interface Ref extends Tuple {
V get();
default V get(Supplier loader) {
V v = get();
if (v == null && loader != null) {
v = loader.get();
}
return v;
}
static Ref of(final E value) {
return new ValueRef<>(value);
}
}