
com.cohere.api.core.Suppliers Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cohere-java Show documentation
Show all versions of cohere-java Show documentation
The official Java library for Cohere's API.
/**
* This file was auto-generated by Fern from our API Definition.
*/
package com.cohere.api.core;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Supplier;
public final class Suppliers {
private Suppliers() {}
public static Supplier memoize(Supplier delegate) {
AtomicReference value = new AtomicReference<>();
return () -> {
T val = value.get();
if (val == null) {
val = value.updateAndGet(cur -> cur == null ? Objects.requireNonNull(delegate.get()) : cur);
}
return val;
};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy