/* * Decompiled with CFR 0.152. * * Could not load the following classes: * org.jspecify.annotations.Nullable */ package net.minecraft.util; import java.util.Objects; import java.util.function.Function; import org.jspecify.annotations.Nullable; public class SingleKeyCache { private final Function computeValue; private @Nullable K cacheKey = null; private @Nullable V cachedValue; public SingleKeyCache(Function computeValue) { this.computeValue = computeValue; } public V getValue(K cacheKey) { if (this.cachedValue == null || !Objects.equals(this.cacheKey, cacheKey)) { this.cachedValue = this.computeValue.apply(cacheKey); this.cacheKey = cacheKey; } return this.cachedValue; } }