
com.github.chaosfirebolt.converter.constants.ResultCachingSupplier Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of roman-numeral-converter Show documentation
Show all versions of roman-numeral-converter Show documentation
Library for converting roman numerals to arabic and vice versa.
package com.github.chaosfirebolt.converter.constants;
import java.util.function.BooleanSupplier;
import java.util.function.Supplier;
class ResultCachingSupplier implements Supplier {
private final Supplier delegate;
private final BooleanSupplier recalculateCondition;
private T cachedValue;
ResultCachingSupplier(Supplier delegate, BooleanSupplier recalculateCondition) {
this.delegate = delegate;
this.recalculateCondition = recalculateCondition;
}
@Override
public T get() {
if (cachedValue == null || recalculateCondition.getAsBoolean()) {
cachedValue = delegate.get();
}
return cachedValue;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy