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

com.g2forge.alexandria.java.function.cache.FixedCachingSupplier Maven / Gradle / Ivy

There is a newer version: 0.0.18
Show newest version
package com.g2forge.alexandria.java.function.cache;

import java.util.function.Supplier;

public class FixedCachingSupplier implements Supplier {
	/** The supplier to cache. Set to null after use to indicate that we already have the result. */
	protected Supplier supplier;

	protected T value;

	public FixedCachingSupplier(Supplier supplier) {
		this.supplier = supplier;
		this.value = null;
	}

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

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy