![JAR search and dependency download from the Maven repository](/logo.png)
com.g2forge.alexandria.java.function.cache.CachingSupplier Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ax-java Show documentation
Show all versions of ax-java Show documentation
Standard Java library and the basis of the ${alexandria.name} project.
package com.g2forge.alexandria.java.function.cache;
import java.util.Objects;
import java.util.function.Function;
import java.util.function.Supplier;
import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
public class CachingSupplier implements Supplier {
protected final Supplier extends I> supplier;
protected final Function super I, ? extends O> function;
protected I input;
protected O output;
@Override
public O get() {
final I input = supplier.get();
if (!Objects.equals(input, this.input)) {
output = function.apply(input);
this.input = input;
}
return output;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy