package com.r3944realms.leashedplayer.utils;

import java.util.function.Supplier;

public class Lazy<T> implements Supplier<T> {

    private final Supplier<T> delegate;
    private T value;

    public Lazy(Supplier<T> delegate) {

        this.delegate = delegate;
    }

    @Override
    public T get() {

        if (this.value == null) {

            this.value = this.delegate.get();
        }

        return this.value;
    }
}